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:
- Atom Editor
- s3cmd
- S3 Browser
- Greenshot
- Python 2.7
- Custom PowerShell
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:
Anytime I send the screenshot to S3 the PowerShell script will do all the appropriate naming and copy a link into my clipboard. Woot.
About the author
Brooks Garrett is a dedicated technologist who specializes in information security. Brooks has spent over 10 years implementing security programs for both the public and private sector including some of the biggest names in the Fortune 500. When he's not managing risk in the corporate environment you can find him at the local firestation where he is a volunteer firefighter.