我目前在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
。
请,谢谢!!
答案 0 :(得分:0)
感谢您的帮助!
我的错误是在gradle脚本中
设置了依赖关系
compile group: 'com.microsoft.azure', name: 'azure-storage', version: '1.2.0'
什么时候应该
compile 'com.microsoft.azure.android:azure-storage-android:0.8.0@aar'