其他分享
首页 > 其他分享> > 使用Transferobserver Android为AWS对象设置权限

使用Transferobserver Android为AWS对象设置权限

作者:互联网

private void beginUpload(String filePath) {
        if (filePath == null) {
            Toast.makeText(this, "Could not find the filepath of the selected file", Toast.LENGTH_LONG).show();
            return;
        }

        File file = new File(filePath);
        TransferObserver observer = transferUtility.upload(Constants.BUCKET_NAME, file.getName(), file);
        observers.add(observer);
        HashMap<String, Object> map = new HashMap<String, Object>();
         Util.fillMap(map, observer, false);
        transferRecordMaps.add(map);
        observer.setTransferListener(new UploadListener());
        simpleAdapter.notifyDataSetChanged();
    }

解决方法:

在当前存储桶和文件(如this)上使用PutObjectRequest设置权限

if(this.publicRead)
{
    por.setCannedAcl(CannedAccessControlList.PublicRead);
}

标签:amazon-s3,android
来源: https://codeday.me/bug/20191119/2032858.html