[英]Local file blob save
I am a bit stuck with this Windows Azure Blob storage. 我对这个Windows Azure Blob存储有些困惑。
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 http:...?filepath = C:/temp/myfile.txt
On the web service I want to get this file and put it on the blob service. 在Web服务上,我想获取此文件并将其放在Blob服务上。 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'.
我总是得到:遇到错误:找不到路径'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.
它是WCF网络角色,似乎与您的部分问题描述相匹配。 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.
但是,大多数Web服务都使用http://whatever.cloudapp.net/whatever.svc以及http://whatever.cloudapp.net/whaterever.aspx?添加了什么。 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. 您还在代码中提到了控制器,这使我认为它是基于MVC的Web角色应用程序。
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. 最后,根据您提供的内容,您正在从本地文件系统(C:\\ temp \\ myfile.txt)中读取文件,并将其上传到Azure Blob。 This will work in compute Emulator and sure will fail in Windows Azure because:
这将在计算模拟器中起作用,并且肯定会在Windows Azure中失败,因为:
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. 在您的Web角色代码中,您将无权在C:\\驱动器上进行写操作,这就是为什么文件不存在并且出现错误的原因。 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本地存储在其中写入任何内容,然后使用本地存储读取文件,然后上载Azure Blob。 Azure Local storage is designed to write any content from web role (you will have write permission).
Azure本地存储旨在写入Web角色中的任何内容(您将具有写入权限)。
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 VM无法持久保存,因此无法在VM中写入任何内容的解决方案就不好了,并且如果可能的话,您可能需要不使用系统内存就直接写入Azure存储。
您是否确认文件在Azure服务器上存在?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.