Combine: Azure blob storage media library and file system media library

Andrew Yang asked on November 12, 2019 15:03

Hi there! I have a question about media libraries. Can I set up media libraries to get this? :

  1. PDF - file system; (https://domain.local/files/pdf/)
  2. Images - Azure blob storage; (https://cdn.domain.local/images/) (root of the blob storage, CDN endpoint)
  3. Other - file system. (https://domain.local/files/other/)

If it's possible than how can I do it?

Thank you.

Recent Answers


Brenden Kehren answered on November 12, 2019 15:51 (last edited on November 12, 2019 16:58)

I don't believe the media library can handle this without problems or custom code. Can I ask why you wouldn't want to put everything in the CDN if you're already going through the trouble of setting it up?

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on November 12, 2019 16:55 (last edited on November 12, 2019 19:35)

You probably can by creating custom providers. Then you would have 3 different mappings based on path (i.e. 3 different provider one for azure blob, one for file system etc), i.e.

 // Maps a directory to the provider
 StorageHelper.MapStoragePath("~/images/", mediaProvider);
 StorageHelper.MapStoragePath("~/pdf/", pdfProvider);
 StorageHelper.MapStoragePath("~/files/", filesProvider);

But I would second Brenden. What exactly the benefit? I'd rather have files store in one place - lets say azure blob and have a process that synchronizes your directory with pdf files on remote directory to azure blob (if they are on remote server). You don't need 3 different storage providers here. It will add complexity without much of a benefit.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.