Upload Form with multiple binary data

Upload Form with multiple binary data

  

Hi, 

Can someone help me out on how to make an entity where i can save/upload multiple images/file?

Basically i should have 1 input form and 7 upload widgets

Hi Rey,

What is your question, exactly?

Is really about how to create attributes in an entity?

Is about how to deal with multiple upload widgets?

Is about how to save things in an entity?

Cheers

Eduardo Jauch

Eduardo Jauch wrote:

Hi Rey,

What is your question, exactly?

Is really about how to create attributes in an entity?

Is about how to deal with multiple upload widgets?

Is about how to save things in an entity?

Cheers

Eduardo Jauch

My question is how do i do about getting multiple binary data sir. Since an entity only holds 1 binary data, how can i save all 7 images/files so it will be tied up with the record.


Rey Kelvin Peralta wrote:

Eduardo Jauch wrote:

Hi Rey,

What is your question, exactly?

Is really about how to create attributes in an entity?

Is about how to deal with multiple upload widgets?

Is about how to save things in an entity?

Cheers

Eduardo Jauch

My question is how do i do about getting multiple binary data sir. Since an entity only holds 1 binary data, how can i save all 7 images/files so it will be tied up with the record.


For example i have a for that has FIRST NAME and LAST NAME, then along with it are 7 upload widgets for 7 different documents. Then after saving it i can add another record with the same fields then i can view them all, so when i click on last name i can see all the images/files that i uploaded under that record. THank you


Hi Rey,

I'll have to ask this... Did you finish the online training on web development? :)
If not, you should. If yes, you should review the part about entities.

The best way to deal with binary files, in this case, is to have an extra entity, with a binary field to hold the content of a file, and extra fields to store file name, file type, document type and a Foreign Key to the main entity (MainId).

Lets assume you have an entity called 'Main', where you store, for example, First Name and Last Name, and an extra entity called 'File', where you store the files.

On submit, you first save the record in 'Main', and than, for each file, you save a record in 'File', setting the fields and using the ID returned by the CreateOrUpdate Main entity action to associate the records with your 'Main' entity. 

Every time you want to recover the files, you just filter the File entity using the MainId

Cheers,
Eduardo Jauch

Hi Rey,

You can save only one binary data in an entity.

So if you want to upload multiple documents for single record, you will need one to many relationship.

You need relationship as shown in attachment.

Here FileData is binary.

Eduardo Jauch wrote:

Hi Rey,

I'll have to ask this... Did you finish the online training on web development? :)
If not, you should. If yes, you should review the part about entities.

The best way to deal with binary files, in this case, is to have an extra entity, with a binary field to hold the content of a file, and extra fields to store file name, file type, document type and a Foreign Key to the main entity (MainId).

Lets assume you have an entity called 'Main', where you store, for example, First Name and Last Name, and an extra entity called 'File', where you store the files.

On submit, you first save the record in 'Main', and than, for each file, you save a record in 'File', setting the fields and using the ID returned by the CreateOrUpdate Main entity action to associate the records with your 'Main' entity. 

Every time you want to recover the files, you just filter the File entity using the MainId

Cheers,
Eduardo Jauch

I Know how to save it in a record, my problem is whne i have multiple images to save on an entity


Suraj Borade wrote:

Hi Rey,

You can save only one binary data in an entity.

So if you want to upload multiple documents for single record, you will need one to many relationship.

You need relationship as shown in attachment.

Here FileData is binary.


So meaning if i have 3 files to save in the entity i should have 3 (ContactDocuments) in my data model?

and if so, how do i use that in my form? does this mean that the Id should have binary data as its type as well? THnaks sir

Suraj Borade wrote:

Hi Rey,

You can save only one binary data in an entity.

So if you want to upload multiple documents for single record, you will need one to many relationship.

You need relationship as shown in attachment.

Here FileData is binary.


So here's what i have,

i cant find the data where i can put in the additional image/file. since attribute1 is in the BookingDetails(Main entity), how do i use File1?

First of all, what is Attribute1 and how does it relate to Documents?

You can access all Documents relevant to a specific BookingDetails by doing an Aggregate that fetches Documents and filters by Documents.BookingDetailId = BookingDetailsId.

Jorge Martins wrote:

First of all, what is Attribute1 and how does it relate to Documents?

You can access all Documents relevant to a specific BookingDetails by doing an Aggregate that fetches Documents and filters by Documents.BookingDetailId = BookingDetailsId.

Hi sir, attribute1 is a binary data that will hold 1 image. since i need to hold several images, i created that data model as a gentleman suggested. so when i made a 2nd upload widget, i need to assign it to File1.

My problem is that i need several images in an entity but 1 entity can only hold 1 binary data. please help out. Thank you very much sir


Rey Kelvin Peralta wrote:

Jorge Martins wrote:

First of all, what is Attribute1 and how does it relate to Documents?

You can access all Documents relevant to a specific BookingDetails by doing an Aggregate that fetches Documents and filters by Documents.BookingDetailId = BookingDetailsId.

Hi sir, attribute1 is a binary data that will hold 1 image. since i need to hold several images, i created that data model as a gentleman suggested. so when i made a 2nd upload widget, i need to assign it to File1.

My problem is that i need several images in an entity but 1 entity can only hold 1 binary data. please help out. Thank you very much sir


So far here is my oml.


Your data model doesn't require BookingDetails to have a binary attribute Attribute1...

You can have as many records of Documents as you want with the same BookingDetailId value: all your images would be stored as Documents records, all with the same BookingDetailId.

Jorge Martins wrote:

Your data model doesn't require BookingDetails to have a binary attribute Attribute1...

You can have as many records of Documents as you want with the same BookingDetailId value: all your images would be stored as Documents records, all with the same BookingDetailId.


Sorry sir but this is a bit confusing for me. How do i do that? how do i use the additional entity to store the additional images. please se my oml. thank you sir.

Rey,

I'd suggest you first go through the Developing OutSystems Mobile Apps course, in particular through the Data in OutSystems and Retrieving Data in OutSystems lessons, to understand how to model your data and how to establish relationships between your entities.

Next you need to understand how to upload a single Image. You have here an explanation of how to use the Upload widget (both Web and Mobile versions).

You can also see here an example of a SilkUI form that uses the Upload widget (all source code available from here).

Basically every time you upload an image to the server you will need to create a new record of type Documents entity, assign all the file data there, assign the Documents.BookingDetailId with the value of the BookingDetailsId screen input parameter (you'll have to pass it as an input parameter to the Server Action) and use the CreateOrUpdateDocuments entity action to save it it to the Database.

Once these are mastered, and if you still have doubts on how to upload multiple images let us know.   

Rey Kelvin Peralta wrote:

Eduardo Jauch wrote:

Hi Rey,

I'll have to ask this... Did you finish the online training on web development? :)
If not, you should. If yes, you should review the part about entities.

The best way to deal with binary files, in this case, is to have an extra entity, with a binary field to hold the content of a file, and extra fields to store file name, file type, document type and a Foreign Key to the main entity (MainId).

Lets assume you have an entity called 'Main', where you store, for example, First Name and Last Name, and an extra entity called 'File', where you store the files.

On submit, you first save the record in 'Main', and than, for each file, you save a record in 'File', setting the fields and using the ID returned by the CreateOrUpdate Main entity action to associate the records with your 'Main' entity. 

Every time you want to recover the files, you just filter the File entity using the MainId

Cheers,
Eduardo Jauch

I Know how to save it in a record, my problem is whne i have multiple images to save on an entity


I DID answer your question, Rey :)
Please, read again my answer, carefully.

But as it is the same recommendation than Jorge, If you prefer, read Jorge's answer.

Cheers,
Eduardo Jauch