使用transferobserver android设置aws对象的权限

时间:2016-02-19 10:01:19

标签: android amazon-s3

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();
    }

1 个答案:

答案 0 :(得分:3)

在当前存储分区上设置PutObjectRequest的权限,并将文件设置为this

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