本文整理匯總了Java中com.amazonaws.services.s3.model.ObjectMetadata.setHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectMetadata.setHeader方法的具體用法?Java ObjectMetadata.setHeader怎麽用?Java ObjectMetadata.setHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.amazonaws.services.s3.model.ObjectMetadata
的用法示例。
在下文中一共展示了ObjectMetadata.setHeader方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateSnapshotIndex
import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
/**
* Write a list of all of the state versions to S3.
* @param newVersion
*/
private synchronized void updateSnapshotIndex(Long newVersion) {
/// insert the new version into the list
int idx = Collections.binarySearch(snapshotIndex, newVersion);
int insertionPoint = Math.abs(idx) - 1;
snapshotIndex.add(insertionPoint, newVersion);
/// build a binary representation of the list -- gap encoded variable-length integers
byte[] idxBytes = buidGapEncodedVarIntSnapshotIndex();
/// indicate the Content-Length
ObjectMetadata metadata = new ObjectMetadata();
metadata.setHeader("Content-Length", (long)idxBytes.length);
/// upload the new file content.
try(InputStream is = new ByteArrayInputStream(idxBytes)) {
Upload upload = s3TransferManager.upload(bucketName, getSnapshotIndexObjectName(blobNamespace), is, metadata);
upload.waitForCompletion();
} catch(Exception e) {
throw new RuntimeException(e);
}
}
示例2: sendToQueueUsingS3
import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
public static String sendToQueueUsingS3(AmazonSQS sqs, String queueUrl, AmazonS3 s3, String bucketName,
Map<String, String> headers, byte[] message, Callable<String> s3IdFactory) {
Preconditions.checkNotNull(sqs);
Preconditions.checkNotNull(s3);
Preconditions.checkNotNull(queueUrl);
Preconditions.checkNotNull(bucketName);
Preconditions.checkNotNull(message);
String s3Id;
try {
s3Id = s3IdFactory.call();
} catch (final Exception e1) {
throw new RuntimeException(e1);
}
final ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(message.length);
for (final Entry<String, String> header : headers.entrySet()) {
metadata.setHeader(header.getKey(), header.getValue());
}
s3.putObject(bucketName, s3Id, new ByteArrayInputStream(message), metadata);
try {
sqs.sendMessage(queueUrl, s3Id);
} catch (final RuntimeException e) {
try {
s3.deleteObject(bucketName, s3Id);
throw e;
} catch (final RuntimeException e2) {
throw new io.reactivex.exceptions.CompositeException(e, e2);
}
}
return s3Id;
}
示例3: 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());
}
示例4: 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);
}
示例5: 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);
}