org.lastbamboo.common.amazon.s3
Interface AmazonS3

All Known Implementing Classes:
AmazonS3Impl

public interface AmazonS3

Interface for interacting with an Amazon S3 repository.


Method Summary
 void createBucket(String name)
          Creates a new bucket.
 void delete(String bucketName, String fileName)
          Deletes the specified file.
 void deleteBucket(String bucketName)
          Deletes the bucket with the specified name.
 void deleteStar(String bucketName, String file)
          Deletes all of the files in the specified bucket matching the specified pattern.
 void getPrivateFile(String bucketName, String fileName, File target)
          Downloads a file from the specified bucket and file name to the specified local path.
 void getPublicFile(String bucketName, String fileName, File target)
          Downloads a file from the specified bucket and file name to the specified local path.
 void listBucket(String bucketName)
          List all the files in the bucket.
 void listBuckets()
          Lists all the user's buckets.
 void normalizeRequest(org.apache.commons.httpclient.HttpMethod method, String methodString, String fullPath, boolean addPublicHeader, boolean useAuth)
          Normalizes the HTTP request headers with things like the authentication token, the date, etc.
 void putPrivateDir(String bucketName, File dir)
          Adds all the files in the specified directory to the specified bucket.
 void putPrivateFile(String bucketName, File file)
          Uploads a file to S3.
 void putPublicDir(String bucketName, File dir)
          Adds all the files in the specified directory to the specified bucket.
 void putPublicFile(String bucketName, File file)
          Uploads a file to S3 that will be publicly available.
 void putPublicFile(String bucketName, File file, String mimeType)
          Uploads a file to S3 that will be publicly available.
 

Method Detail

createBucket

void createBucket(String name)
                  throws IOException
Creates a new bucket.

Parameters:
name - The name of the bucket.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

deleteBucket

void deleteBucket(String bucketName)
                  throws IOException
Deletes the bucket with the specified name.

Parameters:
bucketName - The name of the bucket to delete.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

putPrivateFile

void putPrivateFile(String bucketName,
                    File file)
                    throws IOException
Uploads a file to S3.

Parameters:
bucketName - The name of the bucket.
file - The file to upload.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

putPublicFile

void putPublicFile(String bucketName,
                   File file)
                   throws IOException
Uploads a file to S3 that will be publicly available.

Parameters:
bucketName - The name of the bucket.
file - The file to upload.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

putPublicFile

void putPublicFile(String bucketName,
                   File file,
                   String mimeType)
                   throws IOException
Uploads a file to S3 that will be publicly available.

Parameters:
bucketName - The name of the bucket.
file - The file to upload.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

getPrivateFile

void getPrivateFile(String bucketName,
                    String fileName,
                    File target)
                    throws IOException
Downloads a file from the specified bucket and file name to the specified local path.

Parameters:
bucketName - The name of the Amazon S3 bucket.
fileName - The name of the file within the bucket.
target - The name of the local file to download to.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

getPublicFile

void getPublicFile(String bucketName,
                   String fileName,
                   File target)
                   throws IOException
Downloads a file from the specified bucket and file name to the specified local path. The specified file must be publicly available in S3.

Parameters:
bucketName - The name of the Amazon S3 bucket.
fileName - The name of the file within the bucket.
target - The name of the local file to download to.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

normalizeRequest

void normalizeRequest(org.apache.commons.httpclient.HttpMethod method,
                      String methodString,
                      String fullPath,
                      boolean addPublicHeader,
                      boolean useAuth)
Normalizes the HTTP request headers with things like the authentication token, the date, etc.

Parameters:
method - The HTTP method.
methodString - The HTTP method string, such as "PUT" or "GET".
fullPath - The full path for the resource.
addPublicHeader - Whether or not to add the header to make a resource publicly accessible, as in:

x-amz-acl: public-read

useAuth - Whether or not to add the authentication header.

delete

void delete(String bucketName,
            String fileName)
            throws IOException
Deletes the specified file.

Parameters:
bucketName - The bucket.
fileName - The file name.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

deleteStar

void deleteStar(String bucketName,
                String file)
                throws IOException
Deletes all of the files in the specified bucket matching the specified pattern. Far from allowing full regular expressions, this just simply allows the star expander at the beginning or end of the file name, or both, such as "*.txt*, "file*" or *ile*".

Parameters:
bucketName - The bucket.
file - The file(s) to delete. This can be of the form "*.txt*, "file*" or *ile*", for example.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

listBucket

void listBucket(String bucketName)
                throws IOException
List all the files in the bucket.

Parameters:
bucketName - The name of the bucket to list.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

putPrivateDir

void putPrivateDir(String bucketName,
                   File dir)
                   throws IOException
Adds all the files in the specified directory to the specified bucket.

Parameters:
bucketName - The name of the bucket to list.
dir - The directory containing files to add.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

putPublicDir

void putPublicDir(String bucketName,
                  File dir)
                  throws IOException
Adds all the files in the specified directory to the specified bucket.

Parameters:
bucketName - The name of the bucket to list.
dir - The directory containing files to add.
Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.

listBuckets

void listBuckets()
                 throws IOException
Lists all the user's buckets.

Throws:
IOException - If we could either could not make a network connection to S3 or could not understand the HTTP exchange.


Copyright © 2013 LittleShoot. All Rights Reserved.