Hello All,

Currently I am trying to display the newly uploaded documents/pictures (which are not saved into db yet) through a popup. I have serialized them and passed them to the popup. 

But it seems like it is not possible to get that done as I only managed to display those with total size of less than 1-5KB, means the encoding size/serialized size of the contents for the remaining files caused them to be not displayed in the popup and showing the error as below:

And as I checked the serialized content of those files with bigger size, they are indeed very long in the debug window. Any suggestion on the workaround for this? As I would want to avoid saving all the newly uploaded docs to DB before checking which of them are really being selected by the users to send to the particular recipient of the request.

Solution

Hi,

Trying to pass files through popup/screen inputs isn't recommended because of what you see - you'll quickly run into URL size limits and a host of other issues. It should always be avoided.

If you use a Modal instead of a popup, you'll still have access to the current Screen scope (the one where the file was uploaded). This way, you could use a local variable to hold the Binary Data while displaying it, before writing it to your database.

If you must use a true popup, or a separate Screen, then you need a more permanent place to hold your binary data - you'd have to use the database for this, but there's still ways to keep it clean. You could use a separate Entity that only serves to hold these temporary files, and clean it periodically.

Solution

Afonso Carvalho wrote:

Hi,

Trying to pass files through popup/screen inputs isn't recommended because of what you see - you'll quickly run into URL size limits and a host of other issues. It should always be avoided.

If you use a Modal instead of a popup, you'll still have access to the current Screen scope (the one where the file was uploaded). This way, you could use a local variable to hold the Binary Data while displaying it, before writing it to your database.

If you must use a true popup, or a separate Screen, then you need a more permanent place to hold your binary data - you'd have to use the database for this, but there's still ways to keep it clean. You could use a separate Entity that only serves to hold these temporary files, and clean it periodically.

 Hi Afonso,

If I were to use a true popup(as our system need to get the popup screen/webblock used by some other screens in the module), how can I save it into the temporary entity? 

Let's say if I uploaded 3 files through the upload popup window, and I save them directly into the temporary entity, then how could I get them displayed at my screen's web block(as the request is not yet created thus no request ID is saved for those uploaded attachments in the temporary entity)?

 

You'd have to generate a unique identifier for your files every time a user visits the upload page. Essentially, a way to distinguish between groups of uploaded files.

I'm not certain of the entire flow, namely who has visibility of what in your popup, but assuming it's user based, you could create an Entity that holds a UserId and a DateTime, and another Entity to hold the Binary Data of each file.

So every time I visit the upload page and upload say, three files, you'd save a record in the first Entity with my UserId and the time of upload, and then three Binary Data lines on the second Entity, associated with the first. On the popup, you could then read this data.

If it's not user based, there's other ways of generating unique identifiers on the fly. You could use a GUID instead of a UserId, for instance.