Ask questions about file upload in outsystems

I have two questions about file upload,One is how to get the file size,One is how to get the file size,I only saw Name,Type and Content, the other is when I upload certain files, I get this error:String or binary data would be truncated. The statement has been terminated.


The application that I created is traditional web app,the widget that I used is File Upload

Thank you very much for your help!

About file size, use BinaryData API and the BinaryDataSize action. 


Cheers,
Nuno Verdasca


About the error, that is actually an SQL Server error. It happens when you try to insert/update a record on the database, with some value that is larger than the database field can hold.

For example, if you create an entity Person, and an attribute Name with Length 50 (which is the default), then it can only store texts up to 50 characters in length. If your user tries to insert a larger name, your application will display that error.

The solution is to identify which is the field that has too small of a Length, and then simply increase it.

Cheers,

Nuno Verdasca


Hi Yi Wang,

UploadContent will give the file size.

and this error is because you are trying to store the data whose length is more than expected. Try to increase the length of attributes where you are storing file name..

Hope it helps

Regards

Seema

Nuno Miguel Verdasca wrote:

About file size, use BinaryData API and the BinaryDataSize action. 


Cheers,
Nuno Verdasca

but I don't know how to use it,Can you elaborate more?



Solution

Yi Wang wrote:

Nuno Miguel Verdasca wrote:

About file size, use BinaryData API and the BinaryDataSize action. 


Cheers,
Nuno Verdasca

but I don't know how to use it,Can you elaborate more?



You need to reference the BinaryData extension's BinaryDataSize function. It returns the size in bytes of a variable of type Binary. If you pass UploadWidget.Content (where UploadWidget is the name of your upload widget), you'll get the number of bytes.


"Referencing" means to add a dependency to an eSpace.

  1. Click the Manage Dependencies... button on the top toolbar
  2. In the Manage Depencies pop-up, select the BinaryData module (left pane), and click the BinaryDataSize action (right pane):
  3. Clik "Ok".
  4. Now you can use the BinaryDataSize action. Since it is also a function, you can directly use it in an expression.


Cheers,
Nuno Verdasca

Solution

Nuno Miguel Verdasca wrote:

Yi Wang wrote:

Nuno Miguel Verdasca wrote:

About file size, use BinaryData API and the BinaryDataSize action. 


Cheers,
Nuno Verdasca

but I don't know how to use it,Can you elaborate more?



You need to reference the BinaryData extension's BinaryDataSize function. It returns the size in bytes of a variable of type Binary. If you pass UploadWidget.Content (where UploadWidget is the name of your upload widget), you'll get the number of bytes.


"Referencing" means to add a dependency to an eSpace.

  1. Click the Manage Dependencies... button on the top toolbar
  2. In the Manage Depencies pop-up, select the BinaryData module (left pane), and click the BinaryDataSize action (right pane):
  3. Clik "Ok".
  4. Now you can use the BinaryDataSize action. Since it is also a function, you can directly use it in an expression.


Cheers,
Nuno Verdasca

Thank you very much, I thought it was a BIF

You don't have to thank us, we are here to help each other.   \o/