本文整理匯總了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);
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}