How to attachment file into the records?

How to attachment file into the records?

  

Hi 

I am new in outsystem, may I know how to attachment a pdf file or word document file into the outsystem when I create a record?


Yes make sure you have record / attributes type as binary. Then you can put image or file into it. You could use file upload widget to do this.

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

But you could always take a look at Forge there are many components available to do this upload file.

hi Hooi!


I subscribe everything that Eric said and one more thing: Use an attribute called "Filename" (where you will put the file name from the source).

In resume, you need to have an upload widget, and in the screen action you need to map the binary attribute and the Filename attribute from the upload widget to the record you want to create/Update.


Hope this helps you!


Best regards,

Ricardo

Also, it is good practice to store Binary data in a seperate table that has just an Id and the Binary data, for performance reasons.

Starting out with OutSystems, I would say this is a good way to store files. At some point, however, you will want to explore alternatives such as storing the files in Amazon S3 and simply saving the URL in the database. Storing files in your database as binary (1) takes up a lot a of space, (2) can affect the performance of the database if you need to get more than a few of these records in a single call, and (3) can hog the bandwidth/resources of your front-end servers when users try to download the file. 

Hi, any example for this? I am unable to map the Filename.

Hi!


The "UpLoadFicheiro" is the upload file widget name.

You need to match the file name from the file in the upload file with the filename attribute in your table.


Hope this can help you!


Best regards,

Ricardo

Ricardo Pereira wrote:

Hi!


The "UpLoadFicheiro" is the upload file widget name.

You need to match the file name from the file in the upload file with the filename attribute in your table.


Hope this can help you!


Best regards,

Ricardo


Hi Ricardo

Thank you for your help.

May I know after upload the file, how to get the upload file from the record? (I notice after upload the file, the link from the upload button is gone) 

How you capture the upload file in the link so that I can open the file from the link?

Thank you

Hooi Hwang Nyan wrote:

Ricardo Pereira wrote:

Hi!


The "UpLoadFicheiro" is the upload file widget name.

You need to match the file name from the file in the upload file with the filename attribute in your table.


Hope this can help you!


Best regards,

Ricardo


Hi Ricardo

Thank you for your help.

May I know after upload the file, how to get the upload file from the record? (I notice after upload the file, the link from the upload button is gone) 

How you capture the upload file in the link so that I can open the file from the link?

Thank you

Hi Hooi,


you need to create an Action with the download widget.

Something like this:

In this widget you configure the file content and the file name. 

You can associate a link widget to this action, like this:

It's this that you need?

Ricardo Pereira wrote:

Hooi Hwang Nyan wrote:

Ricardo Pereira wrote:

Hi!


The "UpLoadFicheiro" is the upload file widget name.

You need to match the file name from the file in the upload file with the filename attribute in your table.


Hope this can help you!


Best regards,

Ricardo


Hi Ricardo

Thank you for your help.

May I know after upload the file, how to get the upload file from the record? (I notice after upload the file, the link from the upload button is gone) 

How you capture the upload file in the link so that I can open the file from the link?

Thank you

Hi Hooi,


you need to create an Action with the download widget.

Something like this:


In this widget you configure the file content and the file name. 

You can associate a link widget to this action, like this:


It's this that you need?

Hi Ricardo

Thank for your help.

I am able to upload and download the file 

However when I download the pdf file, the file cannot be open it give me this error

 


When I upload abc.docx file, it seem cannot upload this file it give error below "String or binary data would be truncated. The statement has been terminated."


May I know Where I have go wrong?

Thank you again.


Hi Hooi Hwang Nyan,

That message usually means that you are trying to fit too much data into a attribute (typically the Length of your attribute is not enough to hold the entire string you're assigning to it)

In your case, most likely the file name you are uploading has more characters than the Filename attribute can hold.

As for the "Failed to load" error, this could mean it's not actually a valid PDF. Did you check whether it has content at all (I've seen such errors with 0 byte "PDFs")?

Hooi Hwang Nyan wrote:

Ricardo Pereira wrote:

Hooi Hwang Nyan wrote:

Ricardo Pereira wrote:

Hi!


The "UpLoadFicheiro" is the upload file widget name.

You need to match the file name from the file in the upload file with the filename attribute in your table.


Hope this can help you!


Best regards,

Ricardo


Hi Ricardo

Thank you for your help.

May I know after upload the file, how to get the upload file from the record? (I notice after upload the file, the link from the upload button is gone) 

How you capture the upload file in the link so that I can open the file from the link?

Thank you

Hi Hooi,


you need to create an Action with the download widget.

Something like this:


In this widget you configure the file content and the file name. 

You can associate a link widget to this action, like this:


It's this that you need?

Hi Ricardo

Thank for your help.

I am able to upload and download the file 

However when I download the pdf file, the file cannot be open it give me this error

 


When I upload abc.docx file, it seem cannot upload this file it give error below "String or binary data would be truncated. The statement has been terminated."


May I know Where I have go wrong?

Thank you again.


Hi Hooi,


Like Jorge said, this may be your text attribute for filename that need to have more length.



Relatively to your PDF download, I subscribe what Kilian said.

Try to see if the original document is not corrupted. If it's not, verify when you do the assign of the binary data and filename if you're mapping to the correct attributes (you can be inserting filename correctly but not the binary data).


Hope this can help.


Best regards,

Ricardo

Hi all

I managed to fix the issue. Now it work. Thank you to all of your help..

Hi Hooi,

Great to hear you fixed it. Can you share what the problem turned out to be? It may help others on this forum to know.

Kilian Hekhuis wrote:

Hi Hooi,

Great to hear you fixed it. Can you share what the problem turned out to be? It may help others on this forum to know.

Hi All

Failed to load PDF document. I added DocumentFile.Id into the Assign. 


For second issue,  "String or binary data would be truncated. The statement has been terminated."

Like Ricardo and Jorge said, I changed the length of the attribute FileType to from 50 to 100.