How to download an image from an URL and then copy to clipboard?

Hi there,

I am trying to copy an image from a direct URL (www.example.com/image.jpg) to the system clipboard.
The URL is saved in the variable: "ab_coverimageURL" and the filename (e.g.: "example.jpg") in "ab_coverimage_filename".

This is what I've tried:

Unfortunately I get this error when trying to download the file:

Once the file is on the desktop the copying to the clipboard works fine via "Read File to Clipboard".

Any suggestions on how to make this work?
Downloading the file to the desktop first is also just a workaround. If there was a way to either copy to the clipboard directly, saving it temporarily or deleting afterwards that would be good too.

Thanks for any help!

1 Like

I think that's the best/easiest solution, although I would save the image to the ~/tmp folder.

To get an image on the Clipboard, from a URL, the image will have to be downloaded into either some app (which will use a temp file) or directly to a file. There is probably a tool out there somewhere that will automate this for you, but it seems to me that you already have a good solution in hand.

After you use the KM "Read to Clipboard", you can then use the KM "File Delete", if you wish.
Files in the ~/tmp folder will be automatically deleted after a week or the next boot of your Mac.

1 Like

I suspect you’re asking curl to write the downloaded image to the Desktop folder (ie, to replace the folder with the image, which you can’t do.

In situations like this, I would normally download it to a specifically named temporary file.

Execute: curl --url “$KMVAR_Whatever” --output /tmp/myimage.jpg
Read File: /tmp/myimage.jpg

You’ll want to ensure that the extension of the file matches though.

Or you can wait for 8.0…

9 Likes

Since it’s now August, the eighth month of the year, surely all these teasers you’ve been dropping are a sign that 8.0’s release is imminent, right? :wink:

1 Like

As soon as I can stop working on it. All the big things are done, just rounding out some stuff.

3 Likes

My understanding is this "Get URL" action won't work to download any file like PDF or video or something like this?

The Get a URL action can get text or an image, but to download a file as a file you probably want to use the curl shell tool via an Execute a Shell Script action.