简体   繁体   中英

Local file blob save

I am a bit stuck with this Windows Azure Blob storage.

I have a controller that receive a file path (local).

So on the web page I do something loke this:

http:...?filepath=C:/temp/myfile.txt

On the web service I want to get this file and put it on the blob service. When I launch it in local there is no problem but when i publish it there is no way to get the file. I always get: Error encountered: Could not find a part of the path 'C:/temp/myfile.txt'.

Can someone help me. Is there a solution ?

First i would say to get proper help you would need to provide better description about your problem. What do you mean by "On the web service"? Is it a WCF web role which seems to match with your partial problem description. However most of the web service use http://whatever.cloudapp.net/whatever.svc as well as http://whatever.cloudapp.net/whaterever.aspx?whatever if added. Have you done something like that in your application.

You have also mentioned the controller in your code which makes me think it is a MVC based Web Role application.

I am writing above information to help you to formulate your question much better next time.

Finally Based on what you have provided you are reading a file from local file system (C:\\temp\\myfile.txt) and uploading to Azure Blob. This will work in compute Emulator and sure will fail in Windows Azure because:

In your Web Role code you will not have access to write on C:\\ drive and that's why file is not there and you get error. Your best bet is to use Azure Local Storage to write any content there and then use Local Storage to read the file and then upload the Azure Blob. Azure Local storage is designed to write any content from web role (you will have write permission).

Finally, I am concern with your application design also because Azure VM are no persisted so having a solution to write to anywhere in VM is not good and you may need to directly write to Azure storage without using system memory, if that is possible anyways.

您是否确认文件在Azure服务器上存在?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM