Is it possible to get Blobs in a case insensitive fashion?

已答复 Is it possible to get Blobs in a case insensitive fashion?

  • 2012年4月26日 18:00
     
      包含代码

    If I have a bit of code:

    CloudBlob blob = container.GetBlobReference(blobUri);
    

    It appears to be case sensitive, i sort of understand this - but is there a way to get blobs in a case insensitive fashion? I could of course list everything in the container and its sub folders, ToLower() it and find it that way but it sounds terribly inefficient!

    Any ideas appreciated

全部回复

  • 2012年4月26日 18:08
     
     
    Nope, blob storage is always case-sensitive. You might want to just lowercase everything before storing it.
  • 2012年4月27日 3:35
    版主
     
     已答复

    Hi,

    Try String.ToLowerInvariant()  method or regular expresstion for case-snsitive, or Check this article:

    http://www.dotnetperls.com/tolower-optimization

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

  • 2012年4月29日 1:20
     
     已答复

    Blob storage is always case-sensitive. If you need case insensitive access directly from an external URL that points to blob storage, I don't think that's possible at the moment. You might be able to make it work using the CDN, but only if you pull from your web role and not from blob storage.

    If you need cases insensitive access from your app (or if you can have your blob URLs point to your web role), one approach would be to store an index in SQL Azure. You would use the DB to do a case insensitive lookup, mapping the incoming name to the actual blob name.

    You could also create a cache in the local webrole filesystem, either with the entire content of the blobs, or with files that just contain the actual name of the blob. NTFS handles filename lookups in a caseless fashion, so you could use it as a mapping layer.


    Check out my book: Ultra-fast ASP.NET: Building Ultra-Fast and Ultra-Scalable Websites using ASP.NET and SQL Server