1

I'm still blocked with any effort to upload a file or read the file from stream on Azure. I tried adding the mime type as previously suggested but still get :

"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

So I am trying to read the file directly into memory and bypass that but this results in exactly the same thing.

Here is the line that triggers the server statement above :

var doc = SpreadsheetDocument.Open(FileUpload1.PostedFile.InputStream, true);

It seems Azure goes to great lengths to prevent reading files from user's machines. I may have to fall back to a desktop app or try another web host.

This is a follow up to my previous question : Browse to file upload fails on Azure website (small file)

Community
  • 1
  • 1
  • I have to assume that this failure has something to do with the fact that I'm reading an .xlsx file. I can code a successful routine if I read a text file and do the inserts from there. – user2084255 Jul 19 '15 at 23:23

1 Answers1

2

You should use azure storage if you are trying to upload a file from users computer to an azure website. Here are the reasons to do so
1. You haven absolutely no control whatsoever on azure website with VMs. So theoretically, for all you know your website is running on two VMs. The first time it got uploaded to 1st VM and the 2nd time when you try to find it, you hit the 2nd VM
2. Your existing VMs can get decommissioned anytime. Azure does not provide any such kind of logs or gurantee.
3. With azure storage the data is persisted until you remove it

Here is link to similar question Upload Picture to Windows Azure Web Site

This is in case you are persisting the file and then reading it on some other request.

If you are processing the file just as it is uploaded and you do not need the reference later on or persist it, you could parse the file on the client side and just send the bytes to website.

Hope this helps.

Community
  • 1
  • 1
Monil Gandhi
  • 544
  • 1
  • 5
  • 13
  • 1
    I am able to get the file into my db as a blob. I'll see if I can read it now. Thanks for this! – user2084255 Jul 17 '15 at 23:12
  • If you are using as a blob, I would highly recommend azure [Blob Storage](https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/). It is very easy, no setup required and right out of box. The cost is significantly lower as well. If you use 20GB in azure storage it will cost you 50 cents (this is not per month or day.) Cheapest VM is 0.018/hr which will cost you $8.64/day. Even azure sql with 2GB will cost $5/month – Monil Gandhi Jul 18 '15 at 23:10
  • Well, this failed in the same way as well. It works locally but fails when published. – user2084255 Jul 19 '15 at 23:16
  • I was able to insert all the data successfully if I read a pipe delimited csv file so I'm going with that for now. I'll post the code that failed as it has some use to people. – user2084255 Jul 19 '15 at 23:18
  • The db method I used was my own table with a blob field as opposed to the Azure Blob Storage method. – user2084255 Jul 19 '15 at 23:29