Karthik Ravichandran
Karthik Ravichandran

Reputation: 1283

Unable to download the image using c#

I am trying to download the image from azure blob storage using the below code

      String fullPath;
        fullPath = path + names[0];
        FileStream fileStreamInput = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
        FileStreamResult fileStreamResult = new FileStreamResult(fileStreamInput, "APPLICATION/octet-stream");
        if (names == null || names.Length == 0)
            fileStreamResult.FileDownloadName = fileStreamInput.Name;
        else fileStreamResult.FileDownloadName = names[0];
        return fileStreamResult;

Here, value for full path was received as https://mycustomazure.blob.core.windows.net/blob1/

names[0] is user.png

But i got the exception The given path's format is not supported enter image description here

How to resolve this issue ?

Upvotes: 0

Views: 99

Answers (2)

Anton Gorbunov
Anton Gorbunov

Reputation: 1444

FileStream not allow get image from web. You should use WebClient class. See here, how you can get image from web

Upvotes: 0

Stan
Stan

Reputation: 26501

https://msdn.microsoft.com/en-us/library/system.io.filestream(v=vs.110).aspx

I don't see a single instance where it says you can use web path to initialise a new FileStream.

Download the file first to local disk and then initialise with local file.

Upvotes: 1

Related Questions