I am making an app that will receive images and then needs to store them in a SQL DB using Nodejs. I need to store a lot of images and query them a lot as well (I need to query the db to see if that image is in there)
From what I have read its better to save the files in the file system and put the path in the DB (cheaper).
I learned to develop using Heroku and Mlab and saving URLs to my DB this will be my first time using the FileSystem.
I read about azure storage options and a rep told me that I can use their blob services and it would be a good fit. But it seems like there is a lot of learning involved to use their services. I tried azure and aws before for another project and everything seems more complicated with them compared to just using git to deploy to heroku, just picking which services and stuff to use and how to use them.
But it seems like the pricing is A LOT cheaper using azure blobs than using e.g. Heroku, although even the pricing is difficult for me to understand with all these services (Heroku DYNOS...)
The thing is as far as I can tell with Heroku I can just make my app, upload the files to the server using the fs module and then save that path to my DB. Whereas to use azure blobs I also have to learn how to use azures API and store the image in the blob.
I have read their documentation:
https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-nodejs-v10
and cant find exactly how I would know the location of the file on the blob so that I could save it to my DB and then how to retrieve that file.
So my questions are as follows:
- Is my best option (cheapest most efficient) to use azure and azure
blobs or are there better options for what I need? - Is it as I see it that their is another layer of complexity in using
azure storage and blobs and is this the norm when using azure & AWS
(are these cloud services whereas the others arent? Heroku also
mentions cloud in their web page but these seem different)???? - Is it worth the hassle to learn about blobs or is it better to just use something more simple to start off?
- Is saving the images to cloudinary and saving the urls to my SQL DB
viable or is that too expensive or inefficient???
Thanks for the help in advance
Answer
I have not tried Heroku, but I can comment on Azure Blobstorage.
The best practice I see is:
Storing images to blobstorages, with
anonymous read-only access to container and saving URLs to database.
As you have only URLs, you app will download images from Azure saving traffic from your server. Generating random string names instead of (1,2,3,... or a,b,c,... or john,doe,jane,...) for each image will restrict user from accessing unauthorized images.
Creating blob storage on Azure is very simple.
- Create a resource (+)
- Select Storage Account
- Create
You will get Storage Account Name and Key from Access Keys tab.
In Storage Account you'll see: Blobs, Files, Tables, Queues.
Go to Blobs:
- Create a new container
- Be careful about Public Access Level for container (I would recommend container)
- Click on container properties (More options icon ...) and get Container URL.
As mentioned in the docs you read, you will need to define
- Storage Account Name
- Key
- Container URL
in your code and use them.
No comments:
Post a Comment