flameshot-org / flameshot

Powerful yet simple to use screenshot software :desktop_computer: :camera_flash:
https://flameshot.org
GNU General Public License v3.0
25.02k stars 1.6k forks source link

Custom domain uploading #178

Open ghost opened 6 years ago

ghost commented 6 years ago

It's nice to have it directly upload to Imgur, but would there be any way to upload it to a personal website, say https://i.taxborn.com/u89fw.png?

guihkx commented 6 years ago

It's much easier to use a wrapper script for that, IMO. I made a script that uploads screenshots to 0x0.st:

First create a .desktop file for your script: ~/.local/share/applications/my-uploader.desktop

[Desktop Entry]
Type=Application
Name=0x0.st screenshot uploader
Categories=Graphics
Comment=Uploads screenshots to 0x0.st using curl
Icon=cloud-upload
Exec=my-uploader %u
Terminal=false

After creating that file, run this:

$ update-desktop-database ~/.local/share/applications


Now create the script itself in: ~/.local/bin/my-uploader. You also need to install curl, notify-send and xclip:

#!/bin/bash
# Dependencies: curl, notify-send, xclip
function _notify()
{
    notify-send --expire-time 2000 \
        --app-name 'my-uploader' \
        --icon 'flameshot' \
        "$1" "$2"
}

if [ ! -f "$1" ]
then
    _notify 'My uploader' 'Error: Invalid screenshot file.'
    exit 1
fi

_notify 'My uploader' 'Uploading screenshot to 0x0.st ...'

res=$(curl --silent --show-error \
        --form "file=@$1" \
        https://0xx0.st 2>&1)

if [[ ${res:0:7} == 'http://' || ${res:0:8} == 'https://' ]]
then
    echo -n "$res" | xclip -selection clipboard
    _notify 'My uploader' 'Success! The link was sent to your clipboard'
else
    _notify 'My uploader' "Error: $res"
fi

Then:

$ chmod +x ~/.local/bin/my-uploader


How to use it: Take a screenshot with Flameshot, click on the icon that says Choose an app to open the capture, then you'll choose "0x0.st screenshot uploader". If the upload succeeds, the image link will be copied to your clipboard.

lupoDharkael commented 6 years ago

I plan to implement a tool to execute user defined scripts when pressed, passing the path of the screenshot as an argument. I think that's the best way to allow arbitrary uploads, manipulations, etc

harkor commented 6 years ago

I modify your script to use with rsync (with sftp)

Edit: Bug with github when I try to paste code :( https://pastebin.com/iWkk7bav

de-don commented 6 years ago

I create Go script for uploading screenshot to sftp server. See it https://github.com/de-don/sftp_uploader

Usage very simple

$ flameshot gui -r  | ./sftp_uploader -r
mosalski commented 5 years ago

Thank you @de-don !

jmgiaever commented 5 years ago

Any news about this? :)

describe19 commented 4 years ago

@guihkx I'm trying your method and it only seems to work if I launch flameshot from the commandline by simply typing 'flameshot', where it outputs logs to the terminal window. If I launch it with 'flameshot gui' or via the application shortcut in my desktop environment (gnome) nothing seems to happen when I click on the 0x0.st screenshot uploader application. The bash script obviously works but why does nothing happen in those other 2 cases - I'd like to assign a shortcut to 'flameshot gui'.

Edit: I changed Terminal=false to Terminal=yes, and it reveals that in the cases the my-uploader doesn't work I see: "There was an error creating the child process for this terminal" "Failed to execute child process “my-uploader” (No such file or directory)" Any help appreciated, thanks.

Edit2: I fixed it by adding the full path to the Exec= line in the .desktop file. Not sure why that was necessary as .local/bin is indeed in my path...

Robin-Sch commented 4 years ago

image @guihkx I use your script, but I added a header to curl, containing a password. (As my upload server I use sharex-server, that's why I need a password). How would I fix this?

mosalski commented 4 years ago

@RobinSchapendonk You could use a solution from @de-don

Robin-Sch commented 4 years ago

I would like to use it on a pterodactyl server of my friend, but then when I get the URL copied to my clipboard, it's wrong (http://domain.com/sftp_username/screenxxx.png), but it should be http://domain.com:port/screenxxx.png. And I would like to have it uploaded in a specific directory, but that doesn't work, it always uploads it in the root directory.

I opened an issue on his repo, as this is a problem with his code

I changed the script a little bit, so it works with sharex-server, but that returns a JSON like {"URL": "http://domain.com/smth.png" }, but I can't figure out how to copy that URL then.

#!/bin/bash
# Dependencies: curl, notify-send, xclip
function _notify()
{
    notify-send --expire-time 2000 \
        --app-name 'my-uploader' \
        --icon 'flameshot' \
        "$1" "$2"
}

if [ ! -f "$1" ]
then
    _notify 'My uploader' 'Error: Invalid screenshot file.'
    exit 1
fi

_notify 'My uploader' 'Uploading screenshot...'

res=$(curl --silent --show-error -H "Password: password" \
        --form "image=@$1" \
        http://domain.com/api/upload 2>&1)

if [[ ${res:0:7} == 'http://' || ${res:0:8} == 'https://' ]]
then
    echo -n "$res" | xclip -selection clipboard
    _notify 'My uploader' 'Success! The link was sent to your clipboard'
else
    _notify 'My uploader' "Error: $res"
fi

But no need for that, I found this, which has an example for flameshot, which works.

de-don commented 4 years ago

@RobinSchapendonk I have Updated the binaries, now it should work for your case.

notmeta commented 3 years ago

I was looking for a solution and ended up adapting a ShareX script someone linked to make it work for an AWS S3 bucket https://github.com/notmeta/flameshot-s3-uploader

Hope this is useful to anyone

alrepin commented 1 year ago

so is there a feature or just crutches?

SkanderHelali commented 1 year ago

so is there a feature or just crutches?

crutches for now.

mmahmoudian commented 1 year ago

@alrepin @SkanderHelali it will never be implemented as such and there is no doubt about that. Only through the Plugin system it should be added. Of course any contribution is welcome. If you don't know how, this link might be useful:

https://flameshot.org/donate/

Please avoid necro-bumping if you are not adding to the discussion/design. Help us keep the threads tidy. If you have a question, the fastest way is to ask via Matrix. Thank you for your understanding.

gander commented 5 hours ago

I am donating this project, and no progress in an interesting direction.