Example usage for com.amazonaws.services.s3 AmazonS3Client putObject

List of usage examples for com.amazonaws.services.s3 AmazonS3Client putObject

Introduction

In this page you can find the example usage for com.amazonaws.services.s3 AmazonS3Client putObject.

Prototype

@Override
    public PutObjectResult putObject(String bucketName, String key, InputStream input, ObjectMetadata metadata)
            throws SdkClientException, AmazonServiceException 

Source Link

Usage

From source file:com.mesosphere.dcos.cassandra.executor.backup.S3StorageDriver.java

License:Apache License

@Override
public void uploadSchema(BackupRestoreContext ctx, String schema) throws Exception {
    final String nodeId = ctx.getNodeId();
    final AmazonS3Client amazonS3Client = getAmazonS3Client(ctx);
    final String key = getPrefixKey(ctx) + "/" + nodeId + "/" + StorageUtil.SCHEMA_FILE;
    final InputStream stream = new ByteArrayInputStream(schema.getBytes(StandardCharsets.UTF_8));

    amazonS3Client.putObject(getBucketName(ctx), key, stream, new ObjectMetadata());
}

From source file:com.netflix.ice.processor.BillingFileProcessor.java

License:Apache License

private void updateLastMillis(long millis, String filename) {
    AmazonS3Client s3Client = AwsUtils.getAmazonS3Client();
    s3Client.putObject(config.workS3BucketName, config.workS3BucketPrefix + filename,
            IOUtils.toInputStream(millis + ""), new ObjectMetadata());
}

From source file:com.shareplaylearn.models.UserItemManager.java

License:Open Source License

/**
 * Writes items to S3, and item metadata to Redis
 *///from  ww w . j a v a  2 s. c  om
private void saveItem(String name, byte[] itemData, String contentType,
        ItemSchema.PresentationType presentationType) throws InternalErrorException {

    String itemLocation = this.getItemLocation(name, contentType, presentationType);
    AmazonS3Client s3Client = new AmazonS3Client(
            new BasicAWSCredentials(SecretsService.amazonClientId, SecretsService.amazonClientSecret));
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(itemData);
    ObjectMetadata metadata = this.makeBasicMetadata(itemData.length, false, name);
    metadata.addUserMetadata(UploadMetadataFields.CONTENT_TYPE, contentType);
    //TODO: save this metadata, along with location, to local Redis
    s3Client.putObject(ItemSchema.S3_BUCKET, itemLocation, byteArrayInputStream, metadata);
}