Skip to content

Instantly share code, notes, and snippets.

@paolobarbolini
Last active February 3, 2017 21:00
Show Gist options
  • Save paolobarbolini/6204de9967a1c8e02bda91f9e82e92b6 to your computer and use it in GitHub Desktop.
Save paolobarbolini/6204de9967a1c8e02bda91f9e82e92b6 to your computer and use it in GitHub Desktop.
Screencloud s3 upload

Screencloud s3 upload

Bash script to upload screenshots created with the screencloud.net client to an s3 bucket.

This script is specific to my configuration (s3 bucket with static website hosting and cloudflare with https enabled)

If you don't have static website hosting or you aren't using something like cloudflare to get https you may need to modify this script to make it work with your configuration.

Setup:

  1. Download the s3-upload.sh script, place it in a folder and give it permission to execute (chmod +x s3-upload.sh)
  2. Install and setup the aws-cli: https://aws.amazon.com/cli/
  3. Open screencloud
  4. Click on Preferences
  5. Open the Online Services tab
  6. Click on More services
  7. Enable the shell script extension
  8. Edit the settings
  9. Set the command to: PATH_TO_SHELL_SCRIPT {s} NAME_OF_THE_S3_BUCKET DATE_FORMAT (for example: %d-%m-%Y.%H:%M:%S) and enable the option to copy the command output to the clipboard
#!/bin/sh
# Copyright (c) 2016-2017 Paolo Barbolini <paolo@paolo565.org>
# Released under the MIT license (https://opensource.org/licenses/MIT)
file_path=$1
s3_bucket=$2
date_format=$3
# The shell scripts plugin doesn't allow to change the way the file name is generated (which you can do for example with the Local File plugin, so this tries to fix it)
file_name=$(basename "$file_path")
file_extension="${file_name##*.}"
formatted_date=$(date "+$date_format")
upload_name="$formatted_date.$file_extension"
aws s3 cp $file_path s3://$s3_bucket/$upload_name > /dev/null
# Delete the temporary file after uploading it
rm $file_path
# This is what gets copied to the clipboard after the upload is completed
echo "https://$s3_bucket/$upload_name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment