1
votes

In my site the user can upload two kind of files:

  • documents (doc, pdf, jpg, zip)
  • avatar image (jpg)

I started creating a private blob container. So I can check that the user that is asking for a file have the rights to download it.

The problem arise when, in a page of the public part of the site, I have to show all the users avatar images. In this case ther is no need to check anything but the avatar image are saved in the same blob container of the documents that is private.

So, the first solution was to create a simple action that receive the file name of the picture and then get it from the blob and push to the out stream. But doing so I give to malicious users the ability to ask for reserved documents using this script. (simply asking for the document file name instead of the avatar image file)

What is the best solution? Creation of two distinct blob container (one private and one public)? Other solutions?

EDIT

Using metadata to mark public files?

1

1 Answers

4
votes

I would suggest creating two different containers. Not only that, but I will also suggest that you do not just push avatars to the stream, but instead publush the full blob URL to the source. Thus you will be able to later use the CDN also! Using a "transparent proxy" action method makes non-sense for public blobs. As for the private blobs - I think your approach is good, but you'll have to perform some security checks before serving the blob contents.