Question

I'm working on a new project. It is a smartphone application made with react-native. In the app, you can create "cards" which are having a title, a description and a photo, taken by the user's phone.

I will use a SQL Server database, hosted on Azure and I'm currently working on the REST-API whit ASP.NET core with the Entityframwork Core. This is basically not a new workflow for me, but I have never done this with file upload and storage.

Now my question is, how can and should I deal with file upload. The most obvious to me is to store the file on some kind of cloud storage server and save the URL to the image in the database so that I can simply have an Image-Tag in my mobile application with the URL as source-property.

Another way, I found is to store the image as a byte array directly to the database. But I don't like this way of doing it, because then I have to transfer the whole image whenever I want to display it.

Is there a common way to achieve this? I really want to use just Azure because I've just started using the free 12-month trial.

Thanks, Roman

Was it helpful?

Solution

You can use Azure Blob storage to upload your images or any other files. You can choose upload the image in the Blob storage and either:

  1. Get the URI of the stored file, and save the URL of the image in the database.
  2. Store the unique reference (which is the file name that you provide when you upload) in the database, download the image from your server and then transfer it on to your front end. (Avoid this option if you want to avoid the overhead of transferring the image from your backend server to your client-side)
Licensed under: CC-BY-SA with attribution
scroll top