com.amazonaws.services.dynamodbv2.datamodeling
Class S3Link

java.lang.Object
  extended by com.amazonaws.services.dynamodbv2.datamodeling.S3Link

Deprecated. These classes have been deprecated, please use the classes in the com.amazonaws.mobileconnectors namespace.

public class S3Link
extends java.lang.Object

An S3 Link that works with DynamoDBMapper. An S3 link is persisted as a JSON string in DynamoDB. This link object can be used directly to upload/download files to S3. Alternatively, the underlying AmazonS3Client and TransferManager can be retrieved to provide full access API to S3.

For example:

 AWSCredentialsProvider s3CredentialProvider = ...;
 DynamoDBMapper mapper = new DynamoDBMapper(..., s3CredentialProvider);
 String username = "jamestkirk";

 User user = new User();
 user.setUsername(username);

 // S3 region can be specified, but is optional
 S3Link s3link = mapper.createS3Link("my-company-user-avatars", username + ".jpg");
 user.setAvatar(s3link);

 // All meta information of the S3 resource is persisted in DynamoDB, including
 // region, bucket, and key
 mapper.save(user);

 // Upload file to S3 with the link saved in DynamoDB
 s3link.uploadFrom(new File("/path/to/all/those/user/avatars/" + username + ".jpg"));
 // Download file from S3 via an S3Link
 s3link.downloadTo(new File("/path/to/downloads/" + username + ".jpg"));

 // Full S3 API is available via the canonical AmazonS3Client and TransferManager API.
 // For example:
 AmazonS3Client s3 = s3link.getAmazonS3Client();
 TransferManager s3m = s3link.getTransferManager();
 // etc.
 
The User pojo class used above:
 @DynamoDBTable(tableName = "user-table")
 public class User {
     private String username;
     private S3Link avatar;

     @DynamoDBHashKey
     public String getUsername() {
         return username;
     }

     public void setUsername(String username) {
         this.username = username;
     }

     public S3Link getAvatar() {
         return avatar;
     }

     public void setAvatar(S3Link avatar) {
         this.avatar = avatar;
     }
 }
 


Method Summary
 ObjectMetadata downloadTo(java.io.File destination)
          Deprecated. Convenient method to synchronously download to the specified file from the S3 object represented by this S3Link.
 ObjectMetadata downloadTo(java.io.File destination, RequestMetricCollector requestMetricCollector)
          Deprecated. Same as downloadTo(File) but allows specifying a request metric collector.
 ObjectMetadata downloadTo(java.io.OutputStream output)
          Deprecated. Downloads the data from the object represented by this S3Link to the specified output stream.
 ObjectMetadata downloadTo(java.io.OutputStream output, RequestMetricCollector requestMetricCollector)
          Deprecated. Same as downloadTo(OutputStream) but allows specifying a request metric collector.
 AmazonS3Client getAmazonS3Client()
          Deprecated.  
 java.lang.String getBucketName()
          Deprecated.  
 java.lang.String getKey()
          Deprecated.  
 Region getS3Region()
          Deprecated.  
 TransferManager getTransferManager()
          Deprecated.  
 java.net.URL getUrl()
          Deprecated. Returns a URL for the location of the object represented by this S3Link.
 void setAcl(AccessControlList acl)
          Deprecated. Sets the access control list for the object represented by this S3Link.
 void setAcl(AccessControlList acl, RequestMetricCollector requestMetricCollector)
          Deprecated. Same as setAcl(AccessControlList) but allows specifying a request metric collector.
 void setAcl(CannedAccessControlList acl)
          Deprecated. Sets the access control list for the object represented by this S3Link.
 void setAcl(CannedAccessControlList acl, RequestMetricCollector col)
          Deprecated.  
 PutObjectResult uploadFrom(byte[] buffer)
          Deprecated. Convenience method to synchronously upload from the given buffer to the Amazon S3 object represented by this S3Link.
 PutObjectResult uploadFrom(byte[] buffer, RequestMetricCollector requestMetricCollector)
          Deprecated. Same as uploadFrom(byte[]) but allows specifying a request metric collector.
 PutObjectResult uploadFrom(java.io.File source)
          Deprecated. Convenience method to synchronously upload from the given file to the Amazon S3 object represented by this S3Link.
 PutObjectResult uploadFrom(java.io.File source, RequestMetricCollector requestMetricCollector)
          Deprecated. Same as uploadFrom(File) but allows specifying a request metric collector.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getKey

public java.lang.String getKey()
Deprecated. 

getBucketName

public java.lang.String getBucketName()
Deprecated. 

getS3Region

public Region getS3Region()
Deprecated. 

getAmazonS3Client

public AmazonS3Client getAmazonS3Client()
Deprecated. 

getTransferManager

public TransferManager getTransferManager()
Deprecated. 

uploadFrom

public PutObjectResult uploadFrom(java.io.File source)
Deprecated. 
Convenience method to synchronously upload from the given file to the Amazon S3 object represented by this S3Link.

Parameters:
source - source file to upload from
Returns:
A PutObjectResult object containing the information returned by Amazon S3 for the newly created object.

uploadFrom

public PutObjectResult uploadFrom(java.io.File source,
                                  RequestMetricCollector requestMetricCollector)
Deprecated. 
Same as uploadFrom(File) but allows specifying a request metric collector.


uploadFrom

public PutObjectResult uploadFrom(byte[] buffer)
Deprecated. 
Convenience method to synchronously upload from the given buffer to the Amazon S3 object represented by this S3Link.

Parameters:
buffer - The buffer containing the data to upload.
Returns:
A PutObjectResult object containing the information returned by Amazon S3 for the newly created object.

uploadFrom

public PutObjectResult uploadFrom(byte[] buffer,
                                  RequestMetricCollector requestMetricCollector)
Deprecated. 
Same as uploadFrom(byte[]) but allows specifying a request metric collector.


setAcl

public void setAcl(CannedAccessControlList acl)
Deprecated. 
Sets the access control list for the object represented by this S3Link. Note: Executing this method requires that the object already exists in Amazon S3.

Parameters:
acl - The access control list describing the new permissions for the object represented by this S3Link.

setAcl

public void setAcl(CannedAccessControlList acl,
                   RequestMetricCollector col)
Deprecated. 

setAcl

public void setAcl(AccessControlList acl)
Deprecated. 
Sets the access control list for the object represented by this S3Link. Note: Executing this method requires that the object already exists in Amazon S3.

Parameters:
acl - The access control list describing the new permissions for the object represented by this S3Link.

setAcl

public void setAcl(AccessControlList acl,
                   RequestMetricCollector requestMetricCollector)
Deprecated. 
Same as setAcl(AccessControlList) but allows specifying a request metric collector.


getUrl

public java.net.URL getUrl()
Deprecated. 
Returns a URL for the location of the object represented by this S3Link.

If the object represented by this S3Link has public read permissions (ex: CannedAccessControlList.PublicRead), then this URL can be directly accessed to retrieve the object data.

Returns:
A URL for the location of the object represented by this S3Link.

downloadTo

public ObjectMetadata downloadTo(java.io.File destination)
Deprecated. 
Convenient method to synchronously download to the specified file from the S3 object represented by this S3Link.

Parameters:
destination - destination file to download to
Returns:
All S3 object metadata for the specified object. Returns null if constraints were specified but not met.

downloadTo

public ObjectMetadata downloadTo(java.io.File destination,
                                 RequestMetricCollector requestMetricCollector)
Deprecated. 
Same as downloadTo(File) but allows specifying a request metric collector.


downloadTo

public ObjectMetadata downloadTo(java.io.OutputStream output)
Deprecated. 
Downloads the data from the object represented by this S3Link to the specified output stream.

Parameters:
output - The output stream to write the object's data to.
Returns:
The object's metadata.

downloadTo

public ObjectMetadata downloadTo(java.io.OutputStream output,
                                 RequestMetricCollector requestMetricCollector)
Deprecated. 
Same as downloadTo(OutputStream) but allows specifying a request metric collector.



Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.