【发布时间】:2017-04-06 12:46:43
【问题描述】:
我正在尝试直接从流上传 Blob,因为我不知道流的长度我决定尝试使用 this answer。
这不起作用,即使它从流中读取并且没有抛出任何异常,内容也没有上传到我的容器中。
我从文件上传没有问题,只有从流上传时才会出现。
这是我的代码,我添加了一些输出来检查它是否正在读取某些内容,但这不是问题:
try {
CloudBlockBlob blob = PublicContainer.getBlockBlobReference(externalFileName);
if (externalFileName.endsWith(".tmp")) {
blob.getProperties().setContentType("image/jpeg");
}
BlobOutputStream blobOutputStream = blob.openOutputStream();
int next = input.read();
while (next != -1) {
System.err.println("writes");
blobOutputStream.write(next);
next = input.read();
}
blobOutputStream.close();
return blob.getUri().toString();
} catch (Exception usex) {
System.err.println("ERROR " + usex.getMessage());
return "";
}
它没有失败,但它不起作用。
还有其他方法吗?还是我错过了什么?
更新:我一直在检查,我认为问题出在 InputStream 本身,但我不知道为什么,因为如果我用它来上传相同的流会正常工作以 Amazon s3 为例
【问题讨论】:
标签: java azure azure-storage azure-blob-storage