问题描述
我在我的应用中使用AWS的Amplify Android库,并且尝试列出项目 就像Storage Amplify docs中提到的那样从S3存储桶中获取:
Amplify.Storage.list("/",{ result ->
Log.i("MyAmplifyApp","Total Items : " + result.items.size)
result.getItems().forEach { item ->
Log.i("MyAmplifyApp","Item: " + item.getKey())
}
},{ error ->
Log.e("MyAmplifyApp","List failure",error)
Toast.makeText(this,"Something went wrong. Please try again.",Toast.LENGTH_SHORT)
.show()
}
)
无论我提供什么路径,我都会拿回0件商品。有任何想法吗?没有 错误记录在logcat中。
注意:
预先感谢!
解决方法
我正在我的存储桶的文件夹中获取一张图像列表。
Amplify.Storage.list("/folderName",{ result ->
Log.i("MyAmplifyApp","Total Items : " + result.items.size)
result.getItems().forEach { item ->
Log.i("MyAmplifyApp","Item: " + item.getKey())
}
},{ error ->
Log.e("MyAmplifyApp","List failure",error)
Toast.makeText(this,"Something went wrong. Please try again.",Toast.LENGTH_SHORT)
.show()
}
)