当前位置: 首页>>代码示例>>Java>>正文


Java PutObjectRequest.withCannedAcl方法代码示例

本文整理汇总了Java中com.amazonaws.services.s3.model.PutObjectRequest.withCannedAcl方法的典型用法代码示例。如果您正苦于以下问题:Java PutObjectRequest.withCannedAcl方法的具体用法?Java PutObjectRequest.withCannedAcl怎么用?Java PutObjectRequest.withCannedAcl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.s3.model.PutObjectRequest的用法示例。


在下文中一共展示了PutObjectRequest.withCannedAcl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uploadFile

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
/**
 * Upload a file which is in the assets bucket.
 * 
 * @param fileName File name
 * @param file File
 * @param contentType Content type for file
 * @return
 */
public static boolean uploadFile(String fileName, File file, String contentType) {
    try {
        if (S3Module.amazonS3 != null) {
            String bucket = S3Module.s3Bucket;
            ObjectMetadata metaData = new ObjectMetadata();
            if (contentType != null) {
                metaData.setContentType(contentType);
            }
            PutObjectRequest putObj = new PutObjectRequest(bucket,
                    fileName, file);
            putObj.setMetadata(metaData);
            putObj.withCannedAcl(CannedAccessControlList.PublicRead);
            S3Module.amazonS3.putObject(putObj);
            return true;
        } else {
            Logger.error("Could not save because amazonS3 was null");
            return false;
        }
    } catch (Exception e) {
        Logger.error("S3 Upload -" + e.getMessage());
        return false;
    }
}
 
开发者ID:webinerds,项目名称:s3-proxy-chunk-upload,代码行数:32,代码来源:AssetsS3.java

示例2: putFile

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
private void putFile(Path from, String key)
{
    PutObjectRequest request = new PutObjectRequest(bucket, key, from.toFile());
    if (cannedAccessControlListOptional.isPresent()) {
        request.withCannedAcl(cannedAccessControlListOptional.get());
    }
    client.putObject(request);
}
 
开发者ID:llibra,项目名称:embulk-output-s3,代码行数:9,代码来源:S3FileOutputPlugin.java


注:本文中的com.amazonaws.services.s3.model.PutObjectRequest.withCannedAcl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。