【发布时间】:2017-08-11 15:14:12
【问题描述】:
我目前在 Android Studio 上使用 Azure Blob 存储。我无法遍历 blob 容器
它告诉我
08-10 00:37:16.073 8538-8594/com.psv.starvision W/System.err: java.util.NoSuchElementException: An error occurred while enumerating the result, check the original exception for details.
08-10 00:37:16.073 8538-8594/com.psv.starvision W/System.err: at com.microsoft.azure.storage.core.LazySegmentedIterator.hasNext(LazySegmentedIterator.java:113)
08-10 00:37:16.073 8538-8594/com.psv.starvision W/System.err: at com.psv.starvision.blobHandler.ListImages(blobHandler.java:81)
Caused by: com.microsoft.azure.storage.StorageException: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
08-11 14:10:05.011 8877-8925/com.psv.starvision W/System.err: at com.microsoft.azure.storage.core.StorageRequest.materializeException(StorageRequest.java:306)
08-11 14:10:05.011 8877-8925/com.psv.starvision W/System.err: at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:177)
08-11 14:10:05.011 8877-8925/com.psv.starvision W/System.err: at com.microsoft.azure.storage.core.LazySegmentedIterator.hasNext(LazySegmentedIterator.java:109)
这是 ListImages.Class
public static String[] ListImages() {
LinkedList<String> blobNames = new LinkedList<>();
try {
CloudBlobContainer container = getContainer();
Log.e( "listimages: ", "container " + container );
Iterable<ListBlobItem> blobs = container.listBlobs();
Log.e( "listimages: ", "blobs " + blobs );
blobNames = new LinkedList<>();
for(ListBlobItem blob: blobs) { // the line that hit an error
blobNames.add(((CloudBlockBlob) blob).getName());
}
Log.e("ListImages: ", "size" + blobNames.size() );
return blobNames.toArray(new String[blobNames.size()]);
} catch (Exception ex){
ex.printStackTrace();
}
return blobNames.toArray(new String[blobNames.size()]);
}
有什么想法吗?有问题的容器不是空的;我可以登录container 和blobs。
请多谢!
【问题讨论】:
-
另一个 SO 线程 stackoverflow.com/questions/31578118/… 的答案可能会有所帮助,这似乎与您的相似。
-
我会调查的,谢谢!
标签: android azure android-studio azure-blob-storage