How to fill a database (with images and videos) from the backend?

How to fill a database (with images and videos) from the backend?

  

Hi guys,

I am new to Outsystems. What I want to build is as follows:

I want to create a mobile app that shows an overview of contacts with associated pictures of those persons. So I created an entity "Contacts" with attributes "Name" and "Picture".

Now what I want is to fill the database from the backend (or import it). But I can't see how to do this. I don't want to add all the content for the app from the frontend (so as a user).


So in general I want to know how to fill a database (with images and videos if possible) from the backend?


Hi Niels,

You have a few options here depending on how exactly you are planning on importing that data. Where will it be available to be imported? Files, webservices, another database?

Hi Niels,

"Now what I want is to fill the database from the backend (or import it). But I can't see how to do this. I don't want to add all the content for the app from the frontend (so as a user)."

I'm not sure I get this part...
Do you mean that you want to synchronize the mobile local storage with the backend database (server storage)?

If so, you should take a look here for offline synchronization: https://success.outsystems.com/Documentation/10/Developing_an_Application/Use_Data/Offline/Offline_Data_Synchronization_Patterns

Or if offline is not a problem and you just want to populate local database from server database than you can just add an aggregate to the server entity and an action to copy this data to local storage (and set any filters you want to set to chose only the data you want to add locally).

Or is your problem the upload of images in the backend?

I recommend the online training, as all of this requirements are discussed there:

For web and mobile patterns: https://www.outsystems.com/learn/paths/

If is something else, please, could you clarify?

Cheers,
Eduardo Jauch

Aurelio Santos wrote:

Hi Niels,

You have a few options here depending on how exactly you are planning on importing that data. Where will it be available to be imported? Files, webservices, another database?

That's exactly the question in general: what would be a good option?
I was planning to import some attributes from an Excel. But I don't know how to import the images.

So for example I want to import the following data:

1. Person
Name = x
Age = y
Image = z

The images are on my local harddrive by the way. 


Eduardo Jauch wrote:

Hi Niels,

"Now what I want is to fill the database from the backend (or import it). But I can't see how to do this. I don't want to add all the content for the app from the frontend (so as a user)."

I'm not sure I get this part...
Do you mean that you want to synchronize the mobile local storage with the backend database (server storage)?

If so, you should take a look here for offline synchronization: https://success.outsystems.com/Documentation/10/Developing_an_Application/Use_Data/Offline/Offline_Data_Synchronization_Patterns

Or if offline is not a problem and you just want to populate local database from server database than you can just add an aggregate to the server entity and an action to copy this data to local storage (and set any filters you want to set to chose only the data you want to add locally).

Or is your problem the upload of images in the backend?

I recommend the online training, as all of this requirements are discussed there:

For web and mobile patterns: https://www.outsystems.com/learn/paths/

If is something else, please, could you clarify?

Cheers,
Eduardo Jauch


Hi Eduardo,


Thank you for replying. 


I did the first online training for mobile app development.

Maybe I formulated it a little vague I have to admit.

What I want is to fill the database (including images) in Service Studio. I have experience with a different RAD platform where the developer could add new records in backend (in case of OutSystems it would be in Service Studio).

But your question "Or is your problem the upload of images in the backend?" is on point.
I just want to add new records with images as attributes to the database.



Eduardo Jauch wrote:

Hi Niels,

"Now what I want is to fill the database from the backend (or import it). But I can't see how to do this. I don't want to add all the content for the app from the frontend (so as a user)."

I'm not sure I get this part...
Do you mean that you want to synchronize the mobile local storage with the backend database (server storage)?

If so, you should take a look here for offline synchronization: https://success.outsystems.com/Documentation/10/Developing_an_Application/Use_Data/Offline/Offline_Data_Synchronization_Patterns

Or if offline is not a problem and you just want to populate local database from server database than you can just add an aggregate to the server entity and an action to copy this data to local storage (and set any filters you want to set to chose only the data you want to add locally).

Or is your problem the upload of images in the backend?

I recommend the online training, as all of this requirements are discussed there:

For web and mobile patterns: https://www.outsystems.com/learn/paths/

If is something else, please, could you clarify?

Cheers,
Eduardo Jauch

I made a stupid mistake.
Want I want is to import static entities. So content provided in the app, rather than data that is created by the users of the app.


So reframing my question: how can I import records of a static entity (including images as an attribute of that static entity)?


Hello,

Short answer: as far as I know, you can't import data directly into static entities. But check if it is possible clicking the right button of the mouse over it and looking the context menu, just to be sure...

Long answer...

You can import data to a normal entity and later convert it to a static entity. But I never tried to upload the excel with "binary" fields. With images converted to base64, as they are "characters", would be possible.

But...

Why not simply import the images to resources deploying to target directory, with meaningful names, set those names in the static entity and simply use the address of the image to show them?

Or even simpler, but not so flexible, import the images to the images folder in service studio and use them with the image widget?

Cheers

Eduardo Jauch

Eduardo Jauch wrote:

Hello,

Short answer: as far as I know, you can't import data directly into static entities. But check if it is possible clicking the right button of the mouse over it and looking the context menu, just to be sure...

Long answer...

You can import data to a normal entity and later convert it to a static entity. But I never tried to upload the excel with "binary" fields. With images converted to base64, as they are "characters", would be possible.

But...

Why not simply import the images to resources deploying to target directory, with meaningful names, set those names in the static entity and simply use the address of the image to show them?

Or even simpler, but not so flexible, import the images to the images folder in service studio and use them with the image widget?

Cheers

Eduardo Jauch

Hi Eduardo,


That sounds in theory like a great solution! 

As a new kid on the block I seem a little confused to make it into reality. Should I type the entire URL in one of the attributes? 


Could you please help me a little bit.


Hi Niels,

You want to use the image in the Mobile, in the Backend web application or in both?

Cheers,
Eduardo Jauch 

Eduardo Jauch wrote:

Hi Niels,

You want to use the image in the Mobile, in the Backend web application or in both?

Cheers,
Eduardo Jauch 

Hi Eduardo,


Only in Mobile. 


Cheers,


Niels


Add the images to the resources folder (Data Layer). 

For each image, set the action "Deploy to Target Directory.
If you don't set a value to the path, the image will be deployed to the root of the module (ex: yourserver/yoourmodule/image.png). If you set a path, like images/xyz, the images will be saved ther (ex: yourserver/yoourmodule/images/xyz/image.png)

To access the images you don't need the full path, a relative path will work, like /images/xyz/image.png

You can use this path in HTML elements in the page or even CSS (like background-image), or in image widgets.


And here is a small example attached.

Just to you to see how to use images in resources :)

Cheers,
Eduardo Jauch

Eduardo Jauch wrote:

Add the images to the resources folder (Data Layer). 

For each image, set the action "Deploy to Target Directory.
If you don't set a value to the path, the image will be deployed to the root of the module (ex: yourserver/yoourmodule/image.png). If you set a path, like images/xyz, the images will be saved ther (ex: yourserver/yoourmodule/images/xyz/image.png)

To access the images you don't need the full path, a relative path will work, like /images/xyz/image.png

You can use this path in HTML elements in the page or even CSS (like background-image), or in image widgets.


Alright! But I can't seem to access the images, since I get an error in the URL

 

However when this works, I want to create a dynamic URL, where for each record a different image will be shown. 


Cheers,


Niels     



Hi,

This is because this field (URL) is a text. You need to enclose the value between quotes (" ").
Regarding the "dynamic" thing, is a matter of setting this value through a variable, for example, or if you have a list, from the current, etc. 


:)


Cheers,
Eduardo Jauch

Thank you so so much Eduardo!!

Eduardo Jauch wrote:

Hi,

This is because this field (URL) is a text. You need to enclose the value between quotes (" ").
Regarding the "dynamic" thing, is a matter of setting this value through a variable, for example, or if you have a list, from the current, etc. 


:)


Cheers,
Eduardo Jauch

Regarding the dynamic URL: you mean to create an attribute like path (like you did in the example) where the path is set as the value of the attribute?

Like this: 

:)

Solution

If your image is in a list, that's exactly what I meant.
:)

Cheers,
Eduardo Jauch

Solution