Retrieve task image or subtask image via api

Python is not my thing at all, but hasn’t it a curl library?

hmmm yeah good call!

I got it working in python via the json api, basically just put this in a for loop iterating over the tasks:

file_id = image['id']
print ('File ID =>',file_id)
file_encoded = ob.downloadTaskFile(file_id=file_id)
file_decoded = base64.urlsafe_b64decode(file_encoded)
file_dir = 'temp/thumb_test/'
file_name = task_title + '_' + str(file_id) + '.png'
print ('File Name =>',file_name)
    with open(file_dir+file_name, mode='wb+') as f:

Maybe I dare ask a question:

  • What happens when you encounter a task file that isn’t a PNG file?
  • Do you check this somewhere?

i did this a long time ago using api with vb, but i dont know didly squat about python. i might be able to find that code and figure out what i did, but it was a full desktop interface for KB.

the api does give you info about the file, “is_image” boolean, and the filename.

  • yes! thought of that for later;

atm ‘.png’ is derived from the ‘name’ key and ‘is_image’ is there for a check also as I have a lot of .mp4s as attachments as well.

Yes, I’m basically making a PySide2 interface probably quite similar to what you’ve made with vb.
atm it is working, so: yay!!! however a bit slow, booo haha

So everything is working now quite nicely, however I have 1 issue with getting attachments via the json api:

What is the fastest way to get a task attachment? It feels like the api is missing something…

currently I am grabbing them via:


then doing this:


but this is quite slow to process, I’m wondering if there is a way to just download the file by task_id instead of querying the task first to get the file_id? or something like that.

file or files? you would have to know the file_id for singular.

if you think there is a faster way, you could, i guess combine the plural into one api action. not sure that would make it faster, possibly. worth a shot.

yeah files. :frowning:

so going through the project and collecting cover images per task card (without knowing the file ids)

ya, like i said, you could create your own api action that does it in one action, but it still would need to iterate through the task to get the file ids, so not sure it would improve the speed, vs 2 api actions. might though.

wait, you said cover images, so are you using the cover images plugin? if so, you know the file id, its stored in metadata. no need to iterate.

yes using ‘cover images’ plugin. ah right so can just grab file ID through the metadata via the API. nice