3

This is what I have now, it works on a single image.

curl -vH "Authorization: Client-ID 3e7a4deb7ac67da" -F image=@/path/to/image https://api.imgur.com/3/upload.xml

to get the result open in your browser, I have

curl -vH "Authorization: Client-ID 3e7a4deb7ac67da" -F image=@/path/to/image https://api.imgur.com/3/upload.xml | grep -Eo '<[a-z_]+>http[^<]+'|sed 's/^<.\|_./\U&/g;s/_/ /;s/<.*>//' | sed  's/^.*imgur\.com\//http:\/\/imgur.com\//g;s/\.[^.]*$//' | xargs xdg-open 

but how can I upload multiple images to an anonymous album ?

I knew I can create an album with

curl -vH "Authorization: Client-ID 3e7a4deb7ac67da" -F "title=imgur"  https://api.imgur.com/3/album

Then I guess I need to make some curl calls on each and every one of my images to add them to the album one by one? Or There is some magic command that I can do all of these in just one curl call? (create the album, upload multiple images, and get the album link back)

Imgur image upload api says there is a album key, but I don't know how to pass it with curl.(I can see the deletehash from the result of last album creation call.)

The ultimate goal is to add some menu to kde dolphin browser( as servicemenu ) Single image upload is already working.

screenshot

Shuman
  • 3,914
  • 8
  • 42
  • 65

1 Answers1

1

find command is your friend.

Suppose you wish to upload all the .png images you could do the below stuff.

find /path/to/images/folder -maxdepth 1 -type f  -name "*.png"  \
     -print0 | while read -rd '' filename
do
curl -vH "Authorization: Client-ID 3e7a4deb7ac67da" \
     -F image=@"$filename" https://api.imgur.com/3/upload.xml
done
Мона_Сах
  • 322
  • 3
  • 12