【发布时间】:2014-06-21 14:32:07
【问题描述】:
我正在尝试将图像上传到 azure blob 存储。我正在为 azure 使用 java SDK。我已经引用了这些库。这是我的代码..
public void uploadImage(View view) {
// Do something in response to button click
try
{
String storageConnectionString =
RoleEnvironment.getConfigurationSettings().get("StorageConnectionString");
CloudStorageAccount storageAccount =
CloudStorageAccount.parse(storageConnectionString);
// Create the blob client
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
// Retrieve reference to a previously created container
CloudBlobContainer container = blobClient.getContainerReference("classifieds");
// Create or overwrite the "myimage.jpg" blob with contents from a local file
CloudBlockBlob blob = container.getBlockBlobReference("myimage.png");
InputStream ims = getAssets().open("myimage.png");
int len =ims.available();
blob.upload(ims,(long)ims.available());
}
catch(Exception ex)
{
System.out.println(ex);
}
}
这是我的错误日志
05-05 15:34:25.295:E/Trace(5195):打开跟踪文件时出错:没有这样的 文件或目录 (2) 05-05 15:34:26.105: I/dalvikvm(5195): 不能 查找方法 com.microsoft.windowsazure.serviceruntime.RoleEnvironment.getConfigurationSettings, 从方法引用 com.example.azuresample.MainActivity.uploadImage 05-05 15:34:26.105: W/dalvikvm(5195):VFY:无法解析静态方法 8441: Lcom/microsoft/windowsazure/serviceruntime/RoleEnvironment;.getConfigurationSettings ()Ljava/util/Map; 05-05 15:34:26.105: D/dalvikvm(5195): VFY: 替换 0x0000 05-05 15:34:26.550 处的操作码 0x71:D/gralloc_goldfish(5195): 没有检测到 GPU 仿真的仿真器。 05-05 15:34:34.254: D/AndroidRuntime(5195): 关闭 VM 05-05 15:34:34.254: W/dalvikvm(5195): threadid=1: 线程以未捕获的异常退出 (组=0x40a13300)05-05 15:34:34.285:E/AndroidRuntime(5195):致命 例外:主要
【问题讨论】:
标签: java android azure azure-blob-storage