Android Photo Windows Clipboard URL

Copying Photo URLs to Windows Clipboard When Taking Photos on Android

Introduces a program that copies the URL to the Windows clipboard when taking photos on Android. This time, when you take images or photos on Android... videos didn't work, the program processes various things internally and ultimately copies the public URL to the Windows 10 clipboard.

Shou Arisaka
5 min read
Nov 24, 2025

This time, I’ll introduce a program that copies the photo URL to the Windows clipboard when you take photos on Android.

Android Photo

I’ll explain this in a way that’s easy to understand even for those without Android development experience. Those who have given up on setting up a development environment can easily get photo URLs using this program.

Android development may seem difficult, but using IFTTT (If This Then That), even people without programming knowledge can easily automate tasks. IFTTT may not be well known in Japan, but it actually includes programming elements and can be applied to many uses.

In this program, I’ll introduce a method to process the photo internally when you take a photo on Android, and ultimately copy the public URL to the Windows 10 clipboard.

Overall Flow

I’ll explain the overall flow of this program. Individual steps are not difficult, but since it uses many technologies, it may take some time. However, once you understand it, you can apply it to other Android app development.

  1. When you take a photo on Android, IFTTT uploads the photo and generates a URL. This URL is sent to the server.
  2. The Sinatra server on Ubuntu receives this information, parses the data, and saves it to a text file.
  3. Read the text file from WSL (Windows Subsystem for Linux) and get the URL. For security reasons, instead of using the URL as is, download it locally, process it, re-upload it to the remote server, and then copy it to the clipboard.

Preparation

You need to prepare the following in advance.

  • Use a WiFi router that supports port forwarding. By setting up port forwarding, you can access the local server from a global IP public URL.

Information on router selection here

sudo apt update
sudo apt install build-essential patch zlib1g-dev liblzma-dev ruby{,-dev} -y
sudo gem install bundler

mkdir -p /mnt/c/pg/ruby_dev && cd $_

sudo bundle init
vim Gemfile
sudo bundle install

Add the following lines to Gemfile.

gem "pry"
gem "sinatra"

Procedure

Below are the steps to execute the program.

  1. Set up port forwarding on your WiFi router. By enabling port forwarding, you can access the local server from outside.

WiFi Router Port Forwarding Settings

  1. Create an applet in IFTTT. Use IFTTT to detect Android photos and send data to the server.

Create IFTTT applet here

  1. Mount Windows folders to enable file synchronization. This allows you to sync local and remote data.

Execute the following command.

sudo mount -t cifs //192.168.0.167/_sync_ ~/share -o user=ifgm2,pass=hoge,dir_mode=0777,file_mode=0777
  1. Start the Sinatra application. Sinatra is a Ruby web application framework that receives data from IFTTT.

Below is an example of Sinatra code.

require "sinatra"
require "open3"
require 'json'
require 'pry'

Encoding.default_external = 'UTF-8'

post "/android-photo" do
    binding.pry
    puts @body = request.body.read
    json = JSON.parse(@body)
    puts text = json["TemporaryPublicPhotoURL"]
    stdout, stderr, statusCode = Open3.capture3( %( bash -ic "printf '#{ text }' > /home/yuis/share/android-photo-url.txt || echo '' " ) )
    puts stdout, stderr, statusCode
end

Use the following command to run the application.

sudo bundle exec ruby dev.rb -o 0.0.0.0
  1. Define functions to use on the WSL side. This program uses two functions: expecto and sharefile.

expecto is a utility for automating SSH connections, and sharefile is a utility that uploads local files to a remote server and copies the URL to the clipboard.

You can check the detailed code for these functions in the following articles.

Also, other functions are defined as follows.

tmpdird()
{
    : tmpdir default;
    dirname=$(plaindate) && cd "${TMPDIR}" && mkdir $dirname && cd $dirname
}

plaindate()
{
    date '+%Y%m%d%H%M%S'
}

random()
{
    ARG1=${1:-32}
    cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $ARG1 | head -n 1
}
  1. On the WSL side, run a script that periodically monitors the file containing command text. This script processes the content when the file is updated and copies it to the clipboard.

Below is an example script.

while true; do
    echo -ne "$(isodate)\tNothing updated.\033[0K\r"

    [[ -s "$SHAREDDIR/android-photo-url.txt" ]] && {
        tmpdird
        wget "$( cat "$SHAREDDIR/android-photo-url.txt" )"
        filename="android_photo_$(random).jpg"
        mv "$( command ls -1 | head -1 )" "${filename}"
        pwd > ~/pwd.txt
        eval "$(echo "expecto 'bash -ic \"cd \\"$(cat ~/pwd.txt)\\" ; sharefile ${filename}\"' $XSERV_PASSWORD")"
        printf "Copied remote photo URL to clipboard."
        > "$SHAREDDIR/android-photo-url.txt"
    }

    sleep 2s
done

This script monitors files, downloads URLs, renames files, copies to clipboard, etc.

By executing these steps, you can build a program that takes photos on Android and easily copies the photo URL to the Windows clipboard. If you have any problems, please ask in the comments.

Share this article

Shou Arisaka Nov 24, 2025

🔗 Copy Links