• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Share to SFTP Upload -> Return HTTPS Weblink to Clipboard

Slone

Lurker
I want to send a screenshot (or other image) through SFTP and return an https link to the clipboard. I want to be able to do this in one action from the share menu, not unlike how Puush works. The https path needs to be customizable and then keep the same file name at the end. I'd like a notification when starting (toast), upon failure (drawer, toast), and upon success (drawer, toast). If you could include a progress bar notification (drawer), that'd be super cool, but isn't necessary.

FTPix pretty much does what I ask, but it does not implement SFTP and hasn't been updated in almost three years.

Here's an example on the desktop using ShareX.

A8J2JhO.png


I'm willing to pay up to $20 through PayPal for a polished, working implementation, just let me know prior to development. I don't want multiple dev's developing the same app and all expecting money. :)
 
I'd still like a GUI with more options, but I did manage to put something together that will find my latest screenshot, upload it to my server, and return a web URL. It ain't pretty, but I'm very much a novice at scripting.

YMMV based on your ROM and busybox version.

This uses rsync to upload from a dedicated upload user and sets group permissions to allow Apache to serve the files. Then, it returns a URL with the correct filename that you just uploaded.

This has a couple of prerequisites:
  • Root privileges.
  • ".ssh" directory created upon every boot in "/". Inside the directory, these files must also exist.
  • - "known_hosts" file with your server's fingerprint.
  • - "config" file to reference your private key, which must be kept in a location that only root can access, with "400" permissions.
  • The clipper service to set the clipboard contents from a script.
  • Busybox.
  • Optional, but I saved the script as a .sh file and used JuiceSSH to run this snippet from my homescreen:
    su
    sh /sdcard/Scripts/Uploader.sh

I didn't put the following in code format so I could bold the things that'll need to be changed for someone else's use.

cd /sdcard/Pictures/Screenshots/ && uploadqueue=$(busybox ls -d -t -1 $PWD/* |head -1) && fname=$(busybox ls -t |head -1) && rsync -a -e 'ssh -p22' --chown=user:group $uploadqueue user@server:/path/to/upload/directory/$fname && echo "" && echo https://url.here/$fname && echo && am broadcast -a clipper.set -e text 'https://url.here/'$fname

I benefited from putting this together. Hopefully, someone else can benefit from it already being done. :)

Also, if you're curious why I used "busybox ls" instead of "ls", I kept getting a broken pipe error with my ROM's version of ls.
 
Back
Top Bottom