简体   繁体   中英

Storing blobs in windows azure store additional data such as content type in DB

We have a fairly large solution which stores a lot of images, videos, documents in Sql Server 2008 using FileStream. We have begin migration to using windows azure blob storage to take advantage of geo-replication and what not, this will mean changing the varbinary(max) columns to a relative url we will append with our custome subdomain we have pointing to our storage account.

This all works fine and we are happy in testing however we currently store with the varbinary data the Filename, extension and contentType.

My question is if we are just going to a relative url which will have the file extension on if needed do we need to store this additional data? We are debating in the office and the consensus seems to be to keep it simple and just store the Url.

What do most people do in this scenario? What are the uses/benefits of storing this addiotnal data?

Many thanks for your thoughts on this, an external opinion is probably all that will settle this.

I tend to keep any metadata about the files I store in Azure, that I think may be useful, in SQL alongside the URI.

What is 'useful'?
This depends really on your scenario. For example, I find it useful (from ops/monitoring point of view) to store the file size against the URI so I can easily and quickly look at file storage usage. I also store the file extension/content type. Basically, I try to hold any metadata locally that could save me otherwise having to actually go off and talk to Azure, a) for speed/performance and b) to minimise the # of hits on the API (and hence reduce costs - only really if you're doing a lot of hits)

So I know that for any reporting needs/UIs that need to maybe detail files available, I can produce that will some useful metadata without having to go anywhere near Azure. And then only actually touch Azure when I do need to get the file.

There are two things which you may find useful: there's a "content type" system property for each blob which can be set when uploading the blob (you can change it later on as well). Another thing is that you can specify custom metadata in form of key value pairs with the blob as well. However the metadata is not searchable. So if you want to search for blobs based on some custom properties, you might be better off storing them outside the blob (SQL server) in your case. Another thing with metadata is the maximum size of it. If I'm not mistaken, there's a limit of 8 KB.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM