當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectMetadata.addUserMetadata方法代碼示例

本文整理匯總了Java中com.amazonaws.services.s3.model.ObjectMetadata.addUserMetadata方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectMetadata.addUserMetadata方法的具體用法?Java ObjectMetadata.addUserMetadata怎麽用?Java ObjectMetadata.addUserMetadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.amazonaws.services.s3.model.ObjectMetadata的用法示例。


在下文中一共展示了ObjectMetadata.addUserMetadata方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createShortUrl

import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
/**
 * The method creates a short URL code for the given url
 * 
 * @param url
 * @return
 */
public ShortUrl createShortUrl(String url, String code) {

	logger.info("storing the url {} in the bucket {}", url, this.bucket);
	// Create the link for the short code
	if (code == null) {
		code = getObjectCode();
	}
	String loadFile = redirectFile.replace("REPLACE", url);
	byte[] fileContentBytes = loadFile.getBytes(StandardCharsets.UTF_8);
	InputStream fileInputStream = new ByteArrayInputStream(fileContentBytes);
	ObjectMetadata metadata = new ObjectMetadata();
	metadata.setContentType("text/html");
	metadata.addUserMetadata("url", url);
	metadata.setContentLength(fileContentBytes.length);
	PutObjectRequest putObjectRequest = new PutObjectRequest(this.bucket, code, fileInputStream, metadata)
			.withCannedAcl(CannedAccessControlList.PublicRead);
	this.s3Client.putObject(putObjectRequest);
	createDummyRecord(url, code);
	return new ShortUrl(url, code);
}
 
開發者ID:weblegit,項目名稱:urlshortner,代碼行數:27,代碼來源:UrlShortnerService.java

示例2: publishSnapshot

import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
public void publishSnapshot(Blob blob) {
    String objectName = getS3ObjectName(blobNamespace, "snapshot", blob.getToVersion());

    ObjectMetadata metadata = new ObjectMetadata();
    metadata.addUserMetadata("to_state", String.valueOf(blob.getToVersion()));
    metadata.setHeader("Content-Length", blob.getFile().length());
    
    uploadFile(blob.getFile(), objectName, metadata);
    
    /// now we update the snapshot index
    updateSnapshotIndex(blob.getToVersion());
}
 
開發者ID:Netflix,項目名稱:hollow-reference-implementation,代碼行數:13,代碼來源:S3Publisher.java

示例3: publishDelta

import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
public void publishDelta(Blob blob) {
    String objectName = getS3ObjectName(blobNamespace, "delta", blob.getFromVersion());
    
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.addUserMetadata("from_state", String.valueOf(blob.getFromVersion()));
    metadata.addUserMetadata("to_state", String.valueOf(blob.getToVersion()));
    metadata.setHeader("Content-Length", blob.getFile().length());
    
    uploadFile(blob.getFile(), objectName, metadata);
}
 
開發者ID:Netflix,項目名稱:hollow-reference-implementation,代碼行數:11,代碼來源:S3Publisher.java

示例4: publishReverseDelta

import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
public void publishReverseDelta(Blob blob) {
    String objectName = getS3ObjectName(blobNamespace, "reversedelta", blob.getFromVersion());
    
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.addUserMetadata("from_state", String.valueOf(blob.getFromVersion()));
    metadata.addUserMetadata("to_state", String.valueOf(blob.getToVersion()));
    metadata.setHeader("Content-Length", blob.getFile().length());
    
    uploadFile(blob.getFile(), objectName, metadata);
}
 
開發者ID:Netflix,項目名稱:hollow-reference-implementation,代碼行數:11,代碼來源:S3Publisher.java

示例5: toObjectMetadata

import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
/**
 * Returns the metadata in the latest format.
 */
private ObjectMetadata toObjectMetadata(ObjectMetadata metadata) {
    // If we generated a symmetric key to encrypt the data, store it in the
    // object metadata.
    byte[] encryptedCEK = getEncryptedCEK();
    metadata.addUserMetadata(Headers.CRYPTO_KEY_V2,
            Base64.encodeAsString(encryptedCEK));
    // Put the cipher initialization vector (IV) into the object metadata
    byte[] iv = cipherLite.getIV();
    metadata.addUserMetadata(Headers.CRYPTO_IV, Base64.encodeAsString(iv));
    // Put the materials description into the object metadata as JSON
    metadata.addUserMetadata(Headers.MATERIALS_DESCRIPTION,
            kekMaterialDescAsJson());
    // The CRYPTO_CEK_ALGORITHM, CRYPTO_TAG_LENGTH and
    // CRYPTO_KEYWRAP_ALGORITHM were not available in the Encryption Only
    // (EO) implementation
    ContentCryptoScheme scheme = getContentCryptoScheme();
    metadata.addUserMetadata(Headers.CRYPTO_CEK_ALGORITHM,
            scheme.getCipherAlgorithm());
    int tagLen = scheme.getTagLengthInBits();
    if (tagLen > 0)
        metadata.addUserMetadata(Headers.CRYPTO_TAG_LENGTH,
                String.valueOf(tagLen));
    String keyWrapAlgo = getKeyWrappingAlgorithm();
    if (keyWrapAlgo != null)
        metadata.addUserMetadata(Headers.CRYPTO_KEYWRAP_ALGORITHM,
                keyWrapAlgo);
    return metadata;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:32,代碼來源:ContentCryptoMaterial.java

示例6: toObjectMetadataEO

import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
/**
 * Returns the metadata in backward compatibility (old) format, so it can be
 * read by older version of the AWS SDK.
 */
private ObjectMetadata toObjectMetadataEO(ObjectMetadata metadata) {
    // If we generated a symmetric key to encrypt the data, store it in the
    // object metadata.
    byte[] encryptedCEK = getEncryptedCEK();
    metadata.addUserMetadata(Headers.CRYPTO_KEY,
            Base64.encodeAsString(encryptedCEK));
    // Put the cipher initialization vector (IV) into the object metadata
    byte[] iv = cipherLite.getIV();
    metadata.addUserMetadata(Headers.CRYPTO_IV, Base64.encodeAsString(iv));
    // Put the materials description into the object metadata as JSON
    metadata.addUserMetadata(Headers.MATERIALS_DESCRIPTION,
            kekMaterialDescAsJson());
    return metadata;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:19,代碼來源:ContentCryptoMaterial.java

示例7: createInstructionPutRequest

import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
protected final PutObjectRequest createInstructionPutRequest(
        String bucketName, String key, ContentCryptoMaterial cekMaterial) {
    byte[] bytes = cekMaterial.toJsonString(cryptoConfig.getCryptoMode())
                              .getBytes(UTF8);
    InputStream is = new ByteArrayInputStream(bytes);
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(bytes.length);
    metadata.addUserMetadata(Headers.CRYPTO_INSTRUCTION_FILE, "");
    InstructionFileId ifileId = new S3ObjectId(bucketName, key)
            .instructionFileId();
    return new PutObjectRequest(ifileId.getBucket(), ifileId.getKey(),
        is, metadata);
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:14,代碼來源:S3CryptoModuleBase.java


注:本文中的com.amazonaws.services.s3.model.ObjectMetadata.addUserMetadata方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。