Downloading Action is 'Uploading'

Downloading Action is 'Uploading'

  
I have a Table List that stores records of Binary Files (PDF) and the information when it was last printed and emailed. Now, I have added a functionality to download the file. I quickly added a link that calls the OutSystem file download action.



Though it works fine, we just noticed that in chrome, it is 'uploading'. Is this a bug?

What is uploading?

It seems to me something else is uploading.
So it depends what you are trying to do in the page itself.

I actually don't have an idea. The action is just that and it is being called by a button with 'submit' method.

Or could this be Chrome's?
depends what you do in the page.

It could be that you are "showing" a binary data in the page, and when submitting evryting is going back to the server again...



that perfectly makes sense. the content being downloaded comes from the table (TableRecords.List.Current.Record_View.FileContent), so maybe that's the reason it 'uploads'.
Hello JC

That's actually the root cause of the problem. When you have a widget on your page and you access the widget's  attribute values in screen actions, like the DownloadFile action, you're actually sending the widget's content with the page to the web browser, and then back again when you press the submit button.

This happens because when you access the widget's values in the screen action, the OutSystems Platform stores those values in the page's ViewState. There's a good post takling about it here.

When we're talking about one or another text or numeric value, the impact is very small, but when we have binary data in the widget's, then the page size increases significantly.

The right pattern to implement your use case, is to fetch the binary content from a new query in the DownloadFile action. You shouldn't access the query from the preparation on the screen action, because it will also store it's contents on the viewstate. You really need to query the binary file in the screen action, and use that content in the Download node.

Hope this information is helpful.

Cheers


Thank you Miguel and J.

I changed the code to just pass the Id of the record and have a SQL to get the Binary File. Now it is downloading as expected.