Uploading files in native app

Hi,

https://success.outsystems.com/Documentation/10/Developing_an_Application/Design_UI/Inputs/Enable_End-Users_to_Upload_Files 

According to this documentation, when uploading files, a local variable needs to be created on that particular screen. Is there a reason for doing this? Because all the along in my forms, i do not create a local variable to hold binary data such as photos. I just set the image content of my upload widget as 

SyntaxEditor Code Snippet

GetItemsById.List.Current.Items.Photo

Is there a difference when using the local variable and using my method? 

Solution

Hi Jolene,

No there is no such difference. The mandatory for using the upload widget is to bind/map a variable place holder of binary data type to hold the upload binary content i.e. the upload widget can be mapped with local variable or it can be mapped with record attribute of an Aggregate Output List; both the Variables are of binary type.

As per the documentation (mentioned Link) the upload widget is mapped with the binary type Local variable because within the User record, we don't have any binary data type attribute available and as per the outsystems best practice the binary value must be stored in separate (extended) table rather than in the main table (it is good practice to have a separate Entity that contains just an Id and the Binary data).


Hope this helps you!


Regards,

Benjith Sam

Solution

Benjith Sam wrote:

Hi Jolene,

No there is no such difference. The mandatory for using the upload widget is to bind/map a variable place holder of binary data type to hold the upload binary content i.e. the upload widget can be mapped with local variable or it can be mapped with record attribute of an Aggregate Output List; both the Variables are of binary type.

As per the documentation (mentioned Link) the upload widget is mapped with the binary type Local variable because within the User record, we don't have any binary data type attribute available and as per the outsystems best practice the binary value must be stored in separate (extended) table rather than in the main table (it is good practice to have a separate Entity that contains just an Id and the Binary data).


Hope this helps you!


Regards,

Benjith Sam

Hi Benjith,

Thanks for replying. Also to clarify, if i were to upload a file (such as pdf), when i save the file (using the required server actions and client actions), the file is then considered to be downloaded in the application? And to allow another user to view the pdf file, i will have to use the file viewer plugin? 


Jolene Kwek wrote:

Benjith Sam wrote:

Hi Jolene,

No there is no such difference. The mandatory for using the upload widget is to bind/map a variable place holder of binary data type to hold the upload binary content i.e. the upload widget can be mapped with local variable or it can be mapped with record attribute of an Aggregate Output List; both the Variables are of binary type.

As per the documentation (mentioned Link) the upload widget is mapped with the binary type Local variable because within the User record, we don't have any binary data type attribute available and as per the outsystems best practice the binary value must be stored in separate (extended) table rather than in the main table (it is good practice to have a separate Entity that contains just an Id and the Binary data).


Hope this helps you!


Regards,

Benjith Sam

Hi Benjith,

Thanks for replying. Also to clarify, if i were to upload a file (such as pdf), when i save the file (using the required server actions and client actions), the file is then considered to be downloaded in the application? And to allow another user to view the pdf file, i will have to use the file viewer plugin? 


Yes Jolene, as per the mentioned comment your understanding is correct. In order to save the file or to view the locally downloaded file you have to use some of the available forge components like File Plugin and File Viewer.


Hope this helps you!


Regards,

Benjith Sam 


Jolene Kwek wrote:

Hi,

https://success.outsystems.com/Documentation/10/Developing_an_Application/Design_UI/Inputs/Enable_End-Users_to_Upload_Files 

According to this documentation, when uploading files, a local variable needs to be created on that particular screen. Is there a reason for doing this? Because all the along in my forms, i do not create a local variable to hold binary data such as photos. I just set the image content of my upload widget as 

SyntaxEditor Code Snippet

GetItemsById.List.Current.Items.Photo

Is there a difference when using the local variable and using my method? 

Their is not difference between using a local variable and a entity attribute of same datatype.

If you use 

GetItemsById.List.Current.Items.Photo

It will first set the image of upload widget stored in database and if you change the image and update the data base it will get updated.

But if you use local variable, you have to manually assign the value from Db to local variable  and vice versa on both actions(fetching and saving to DB). 


Hope this helps you.


Thanks,

Preeti Kumari

Benjith Sam wrote:

Jolene Kwek wrote:

Benjith Sam wrote:

Hi Jolene,

No there is no such difference. The mandatory for using the upload widget is to bind/map a variable place holder of binary data type to hold the upload binary content i.e. the upload widget can be mapped with local variable or it can be mapped with record attribute of an Aggregate Output List; both the Variables are of binary type.

As per the documentation (mentioned Link) the upload widget is mapped with the binary type Local variable because within the User record, we don't have any binary data type attribute available and as per the outsystems best practice the binary value must be stored in separate (extended) table rather than in the main table (it is good practice to have a separate Entity that contains just an Id and the Binary data).


Hope this helps you!


Regards,

Benjith Sam

Hi Benjith,

Thanks for replying. Also to clarify, if i were to upload a file (such as pdf), when i save the file (using the required server actions and client actions), the file is then considered to be downloaded in the application? And to allow another user to view the pdf file, i will have to use the file viewer plugin? 


Yes Jolene, as per the mentioned comment your understanding is correct. In order to save the file or to view the locally downloaded file you have to use some of the available forge components like File Plugin and File Viewer.


Hope this helps you!


Regards,

Benjith Sam 


Hi,

Alright. Thank you !


Preeti Kumari wrote:

Jolene Kwek wrote:

Hi,

https://success.outsystems.com/Documentation/10/Developing_an_Application/Design_UI/Inputs/Enable_End-Users_to_Upload_Files 

According to this documentation, when uploading files, a local variable needs to be created on that particular screen. Is there a reason for doing this? Because all the along in my forms, i do not create a local variable to hold binary data such as photos. I just set the image content of my upload widget as 

SyntaxEditor Code Snippet

GetItemsById.List.Current.Items.Photo

Is there a difference when using the local variable and using my method? 

Their is not difference between using a local variable and a entity attribute of same datatype.

If you use 

GetItemsById.List.Current.Items.Photo

It will first set the image of upload widget stored in database and if you change the image and update the data base it will get updated.

But if you use local variable, you have to manually assign the value from Db to local variable  and vice versa on both actions(fetching and saving to DB). 


Hope this helps you.


Thanks,

Preeti Kumari

Hi Preeti,

Alright got it! Thanks for replying.