new paper

This commit is contained in:
Evgenii Alekseev 2016-12-16 14:17:25 +03:00
parent 3196df0303
commit 9944fd8019
2 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,45 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: linux, s3
title: How to upload screenshots to S3 from linux
short: upload-screenshots-to-s3
---
For some reasons I'm forced to upload screenshots to S3 instead of public resourses.
This paper describes simple solution which allows to upload screenshots and get
link to it directly from screenshot tool.
<!--more-->
## Requirements
1. Screenshot tool which allows to use custom applications to open image (I use
[Spectacle](//www.kde.org/applications/graphics/spectacle/)).
2. Installed and configured [s3cmd](//s3tools.org/s3cmd).
3. Installed [xsel](//linux.die.net/man/1/xsel) to copy URL to clipboard.
4. Text editor.
## Desktop file
Create desktop file in `$HOME/.local/share/applications/s3cmd.desktop` with the
following content
```ini
[Desktop Entry]
Name=s3cmd
Exec=s3cmd put --acl-public %U "s3://bucket-name/path/to/screenshots/`uuidgen`.png" | grep "Public URL" | cut -d ':' -f 2- | xsel -bi
Icon=image
Type=Application
Terminal=true
Categories=Graphics;
MimeType=image/png;
```
The magic is in `Exec=` parameter. It uses path to temporary created file (`%U`),
uploads image to S3 by using `s3cmd` and gets URL from it with some bash magic.
## Usage
Just do screenshot and open it with `s3cmd`.

View File

@ -0,0 +1,48 @@
---
category: ru
type: paper
hastr: true
layout: paper
tags: linux, s3
title: Как загрузить скриншот в S3 с помощью linux
short: upload-screenshots-to-s3
---
По ряду причин я вынужден загружать скриншоты в S3 вместо доступных публичных
ресурсов. Статья описывает простое решение, которое возволяет загрузить скриншоты
в S3 и возвращает ссылку на него, которое может быть использовано напрямую из
приложения для скриншотов.
<!--more-->
## Требования
1. Скриншотилка, которая позволяет использовать произвольные приложения для
открытия изображения (я использую [Spectacle](//www.kde.org/applications/graphics/spectacle/)).
2. Установленный и настроенный [s3cmd](//s3tools.org/s3cmd).
3. Установленный [xsel](//linux.die.net/man/1/xsel) для копирования ссылки в
буфер обмена.
4. Текстовый редактор.
## Desktop файл
Создайте desktop файл `$HOME/.local/share/applications/s3cmd.desktop` следующего
содержания
```ini
[Desktop Entry]
Name=s3cmd
Exec=s3cmd put --acl-public %U "s3://bucket-name/path/to/screenshots/`uuidgen`.png" | grep "Public URL" | cut -d ':' -f 2- | xsel -bi
Icon=image
Type=Application
Terminal=true
Categories=Graphics;
MimeType=image/png;
```
Основная магия в параметре `Exec=`. Он использует путь к временному файлу (`%U`),
загружает картинку в S3, используя `s3cmd` и возвращает ссылку с использованием
небольшой магии на bash.
## Использование
Просто сделайте скриншот и откройте его с помощью `s3cmd`.