I'm trying to create an Automator app that would work like this:
Steps 1 and 2 are working. I've also found a shell script that can be used to upload files to Dropbox with a provided access token. So I can make it upload the converted JPEG, as that seems to be what the $1
variable is holding in the script.
Here's the shell script:
DROPBOX_TOKEN="YOUR DROPBOX ACCESS TOKEN GOES HERE"
FILE=$1
FILENAME=$(basename "$FILE")
UPLOAD=`curl -sX POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer $DROPBOX_TOKEN" \
--header "Dropbox-API-Arg: {\"path\": \"/$FILENAME\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary @"$FILE"`
I'm also attaching this screenshot of how the current "Automator flow" looks like. In the current state of this "flow", the file that gets uploaded through the shell script is the converted file.
The part I'm stuck at is how to first upload the original image file with one shell script and then upload the converted file with another shell script. I guess that I have to store a reference for both in some way?
I'm also not quite sure how to specifically delete the JPEG after everything is done.
I think with the Set Value of Variable and Get Value of Variable actions you can achieve what you're trying to do here.
This workflow provides an example of using these. You can set multiple different named variables, and then read and reuse them later. To get this workflow to work properly I had to select Ignore this action's input
for the Get step, otherwise it used both the value of example
(which was the filename of the file dropped onto the app) and also the output of Ask for confirmation (which was the filename again, so it tried to move the same file to the Trash twice).
When creating a variable you just choose New Variable...
from the drop-down menu. You then give it a name, and leave the Value box empty (and it gets set from the Set... action's input).
Once you have a Variable set up you can also drag it into some places (from the Variable section at the bottom of the window), as I've done here to make the file path show up in the Ask for Confirmation action. You can also remove any unused variables by right-clicking on the variable in the Variable section, and choosing Delete exampleVariable
Full steps which I think would complete your full workflow could be:
original
(or something), then the parts of the workflow you already have:converted
to inputconverted
back in (this should have Ignore this action's input
ticked)original
back in (this should also have Ignore this action's input
ticked)