當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。