(semi) Automate coverimage uploads

Hi

We work in a visual industry and put a thumbnail on every task using coverimage and its been an awesome tool.
However for larger jobs the number of actions to upload the images is getting irksome:
click on the task and click “attach document”
click “choose files”
choose the file!
click “upload files”
click “close this window”
then the drop down menu to set the image as the thumbnail
close the task

Is there a way of automating this or at least in reducing the number of steps required?
We’re looking at uploading the tasks themselves using a csv file. A pointer in there to an image file that is then configured as the thumbnail would be great.

Thanks
Murray

Hi Murray,

the image which is set as cover image is saved in the task metadata.

So your mass upload has to set the task metadata “coverimage” to the image id of the uploaded task.

You could write a small script which uses the API or a plugin for your board.

  1. create the task
  2. attach the file
  3. set image id as metadata

Thanks BlueTeck. I’ll browse those doc links over the next few days and see if any of that is within my capabilities.

This looks like its going to work but I’m stuck on the syntax for calling saveTaskMetadata(). I’m neither a python nor json programmer!

Given I have the image id in thumbnail_id and the metaName is “coverimage”, how do I pass them to this call?
kb.saveTaskMetadata(task_id=task_id, …

many thanks
Murray

So you are going with python? Could you share a few more lines of your code? :wink:

Sure, its hardly secret…

`def createShot(shotName,thumbnailPathFileName):
#authenticate as user
kb = Kanboard(‘https://URL to my kanboard jsonrpc.php’, userName, token)
kb.get_my_projects()

#get the project
project = kb.getProjectByName(name=projectName)
project_id=project['id']

#create a task
task_id = kb.create_task(project_id=project_id, title=shotName)

# encode the image as a base64 string
with open(thumbnailPathFileName,"rb") as image_file:
	encoded_string = base64.b64encode(image_file.read())

thumbnailFileName = ntpath.basename(thumbnailPathFileName) 
thumbnail_id = kb.createTaskFile(project_id=project_id,task_id=task_id,filename=thumbnailFileName, blob=encoded_string)

#set metadata to make coverimage display the image
kb.saveTaskMetadata(task_id=task_id,   ??? thumbnail_id  ???

`

I just don’t know how to specify the metadata data as a parameter that saveTaskMetadata() will accept - more correctly, python will interpret correctly. json is expecting an array.

The rest of the code works as expected.

Thanks

Edit: hmm, can’t get the formatting to make sense but I think you’ll get the idea :slight_smile:

I found it. Even though the API is asking for an ‘array’ I got it to work sending a python dictionary. So the last line should be:

kb.saveTaskMetadata(task_id=task_id, values={“coverimage”:thumbnail_id})

and a new task complete with thumbnail displayed pops up on my kanboard.
Thanks for your help
Murray

Sorry for my late answer, but you figured it out :slight_smile: