Rename image files storaged in aws instead of "original.jpeg" etc

i was thinking about this since the thread popped up again, and i don’t think this will work.

from what i gather, the download attribute in anchor tags works only same-origin. since the images come from a different host, i think you’ll need a more complicated mechanism to download images to a different filename. (i tried it by using my browser’s dev tools to edit the HTML of an observation page, and download works for things coming from www.inaturalist.org, but not for things coming from other hosts.)

that said, there still are other ways to automate download to a different filename…

i made a small modification to https://jumear.github.io/stirfry/iNatAPIv1_observations which may help folks in some cases. it can now display a column that provides cURL commands to download photos, setting the destination filenames to include one or more prefixes. for example, https://jumear.github.io/stirfry/iNatAPIv1_observations?id=139619286&options=photocurl&photo_curl_filename_prefix=obs_id,obs_seq,photo_id will take you to a page that looks like this:

you can copy the text from the last column:

curl https://inaturalist-open-data.s3.amazonaws.com/photos/238838746/original.jpeg -o 139619286_01_238838746_original.jpeg https://inaturalist-open-data.s3.amazonaws.com/photos/238838763/original.jpeg -o 139619286_02_238838763_original.jpeg https://inaturalist-open-data.s3.amazonaws.com/photos/238838781/original.jpeg -o 139619286_03_238838781_original.jpeg https://inaturalist-open-data.s3.amazonaws.com/photos/238838796/original.jpeg -o 139619286_04_238838796_original.jpeg https://inaturalist-open-data.s3.amazonaws.com/photos/238838841/original.jpeg -o 139619286_05_238838841_original.jpeg

… and if you paste and run that from your OS command line in the directory where you want to save the photos, cURL will download the photos associated with observation, prefixing the filenames with observation id, observation sequence, and photo id.

there are many other ways to automate, but i thought this would be a relatively simple but flexible approach that most folks could understand and use without too much effort.

1 Like