Azure Blob Not Storing PDFs

2019-06-04 04:44发布

问题:

Ok so i have the following code-- it works perfectly for storing jpgs, but does not store pdfs. Any idea why?

 public bool TryStoreImage(string uri, string fileName)
    {
        try
        {
            WebClient wc = new WebClient();
            var blob = new BlobStorage().GetCloudBlobContainer();

            var store = blob.GetBlobReference(fileName);
            store.UploadByteArray(wc.DownloadData(uri));
            return true;
        }
        catch (Exception exc)
        {
            return false;
        }
    }

`

Again, every pdf i try to access gives me "pdf does not exist," even though i can see the pdf in the azure management screen. Every jpg i store however is perfectly accessible.

回答1:

What do you mean by "pdf does not exist?" What tool is telling you that? How are you accessing the blob? Without knowing that, it's impossible to really figure it out, but I'd speculate that the lack of a content-type is a problem. Try store.Properties.ContentType = "application/pdf".

– smarx