· aws blog

Screenshot to S3

I’ve been writing in pure markdown for a while and one portion of my workflow still gives me trouble.

Images.

Today I threw together a simple solution for managing images and thought I’d share in case someone else has issues.

Tools I’m using:

I publish in Atom. I host in S3. All my rich content (image, video, presentation, etc.) lives on https://data.brooksgarrett.com/. I’m using S3 Browser to manually upload images as needed.

What I’ve changed is using Greenshot for screen capture. Greenshot has a send to external command plugin. I created a simple PowerShell script to use s3cmd to upload images directly from Greenshot.

param (
    [string]$bucket = "s3://data.brooksgarrett.com",
    [string]$prefix = "/uploads/",
    [string]$filename = $( throw "-filename Required" )
 )

if ($bucket.EndsWith("/"))
{
    $bucket=$bucket.Substring(0,$bucket.Length-1)
}

if (!$prefix.StartsWith("/"))
{
    $prefix = "/$prefix"
}

if (!$prefix.EndsWith("/"))
{
    $prefix = "$prefix/"
}

if ($filename.Contains("\"))
{
    $parts = $filename.Split("\")
    $shortfilename = $parts[$parts.Length-1]
}

C:\Python27\python.exe "C:\s3cmd\s3cmd" "put" "$filename" "$bucket$prefix$shortfilename"

"$bucket$prefix$shortfilename".Replace("s3", "https") | clip.exe;

Then in Greenshot I simply added the script as an external command:

Greenshot External Command

Anytime I send the screenshot to S3 the PowerShell script will do all the appropriate naming and copy a link into my clipboard. Woot.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket