Amazon S3 (Simple Storage Service)

Amazon Web Services

Docs

Setting up a public-read bucket

S3 can be used as a public image/file server.

  1. Create a bucket.
  2. Set a bucket policy.

Example:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicRead",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject",
                "s3:GetObjectVersion"
            ],
            "Resource": "arn:aws:s3:::bucketname/foldername/*"
        }
    ]
}
  1. maybe create an IAM role/group for the S3 access to keep it isolated from other AWS.
  2. Add the credentials to ~/.aws/credentials.
  3. You can install/use AWS CLI to upload files. For instance,
#!/bin/zsh
aws s3 --profile yours3profile cp $1 s3://bucketname/foldername/
filename=$1:t
echo "https://bucketname.s3.amazonaws.com/slides/$filename" | pbcopy
mv $1 /some/where/you/want
  1. You can use this script for a Hazel automation (e.g., if you drag a file into a specific folder, Hazel will upload it to S3, copy the URL, and then move the file to somewhere you want). You can also add a Keyboard Maestro automation to add an image tag with the S3 URL. Actually this is how I manage image files on YYiki.

Libraries