AnnotationHub (version 2.4.2)

upload_to_S3: Upload a file to Amazon S3

Description

This function is for uploading a file resource to the S3 cloud.

Usage

upload_to_S3(file, remotename, bucket, profile, acl="public-read")

Arguments

file
The file to upload.
remotename
The name this file should have in S3, including any "keys" that are part of the name. This should not start with a slash (if it does, the leading slash will be removed), but can contain forward slashes.
bucket
Name of the S3 bucket to copy to.
profile
Corresponds to a profile set in the config file for the AWS CLI (see http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-multiple-profiles{the documentation}). If this argument is omitted,the default profile is used.
acl
Should be one of private, public-read, or public-read-write.

Value

  • TRUE on success. If the command fails, the function will exit with an error.

Details

Uses the https://aws.amazon.com/cli/{AWS Command Line Interface} to copy a file to Amazon S3. Assumes the CLI is properly configured and that the aws program is in your PATH. The CLI should be configured with the credentials of a user who has permission to upload to the appropriate bucket. It's recommended to use https://aws.amazon.com/iam/{IAM} to set up users with limited permissions.

There is an RAmazonS3 package but it seems to have issues uploading files to S3.

Examples

Run this code
upload_to_S3("myfile.txt", "foo/bar/baz/yourfile.txt")
# If this is successful, the file should be accessible at 
# http://s3.amazonaws.com/annotationhub/foo/bar/baz/yourfile.txt

Run the code above in your browser using DataLab