Retrieve task image or subtask image via api

Hi,

great software!

how do I retrieve a task/subtask image from kanboard via the api? (I’m using python btw)

img image urls are encoded such as:
blob:https://pathToKanboard/a065797d-3e24-4f5b-936b-c41e3740ce4f

requesting the data goes ok, but I have no idea what to do with the return value(path); presumably rename it and stick a .png on the end of the string?:

“thumbnail”: [
{
“id”: 17,
“name”: “Screenshot taken 17/09/2022 10:22 pm.png”,
“path”: “tasks/11/db93e016c2961cf5c3571ee5975418a6f2f28fc7”,
“is_image”: 1,
“task_id”: 11,
“date”: 1663410171,
“user_id”: 1,
“size”: 135882,
“username”: “durp”,
“user_name”: “Admin”

Cheers

Yes, at least if you are certain that db93e016c2961cf5c3571ee5975418a6f2f28fc7 indeed IS a PNG file.

on another note:

my image attachment urls look like this:
/?controller=FileViewerController&action=image&task_id=17&file_id=1

any idea how to change that to .png? the server does it when you download the file…

I think I will be downloaded with the correct content-type, no need to append something.

https://my.kanboard.url/?controller=FileViewerController&action=image&task_id=17&file_id=1

python doesn’t seem to know what to do with a link like this as I think the image returned is stored in the browser’s cache?

also something like this is not a valid link:
“tasks/19/822d018cd53d31f5832f71a83bbd1322f317db5a.png”

for example this just redirects me to the login page or whatever the .htaccess is telling it to:
https://my.kanboard.url/tasks/19/822d018cd53d31f5832f71a83bbd1322f317db5a.png

I guess my question really is: how do I build a link with this json response?

“id”: 2,
“name”: “Screenshot taken 29/08/2022 10:04 pm.png”,
“path”: “tasks/19/822d018cd53d31f5832f71a83bbd1322f317db5a”,
“is_image”: 1,

Well, then you have both components you need:

server-url + path + extension from name

I think this is the actual file path:

https://my.kanboard.url/data/files/tasks/19/822d018cd53d31f5832f71a83bbd1322f317db5a

but returns a Forbidden 403 :melting_face:

so I’ve tired these so far (none appear to be working):

blob:https://my.kanboard.url/a065797d-3e24-4f5b-936b-c41e3740ce4f
blob:https://my.kanboard.url/a065797d-3e24-4f5b-936b-c41e3740ce4f.png
https://my.kanboard.url/?controller=FileViewerController&action=image&task_id=11&file_id=1
https://my.kanboard.url/?controller=FileViewerController&action=download&task_id=11&file_id=1
https://my.kanboard.url/tasks/19/a065797d-3e24-4f5b-936b-c41e3740ce4f.png
https://my.kanboard.url/data/files/tasks/19/822d018cd53d31f5832f71a83bbd1322f317db5a
https://my.kanboard.url/data/files/tasks/19/822d018cd53d31f5832f71a83bbd1322f317db5a.png

OK, I see. This doesn’t work.

Yeah or I’m totally doing it wrong…
but that would mean the ‘path’ key in the json return is redundant?
{
“id”: 6,
“name”: “someFile.png”,
“path”: “tasks/20/eea922f6d0cd65fba32dbbe673dc4e5684aa0ea8”,
“is_image”: 0,
“task_id”: 20,
“date”: 1661774275,
“user_id”: 1,
“size”: 2632807,
“username”: “Some Noob”,
“user_name”: “Admin”
},

You have to find a way, that python can deal with a totally legal URL. :wink:

yeah… This url is being rendered by the browser and I don’t think it’s accessible outside a browser. I could be wrong.

https://my.kanboard.url/?controller=FileViewerController&action=image&task_id=17&file_id=1

like this would be totally accessible from anywhere I think:
https://my.kanboard.url/path/to/my/file/fileName.png

Sorry, but it’s not a browser thing, there is as specification for a URL.

       userinfo        host      port
        ┌──┴───┐ ┌──────┴──────┐ ┌┴┐
https://john.doe@www.example.com:123/forum/q/?tag=networking#top
└─┬─┘   └───────────┬──────────────┘└┬──────┘ └──┬──────────┘└┬┘
scheme          authority           path        query      fragment

Any piece of software should be able to deal with it.

yeah I’d thought it would be pretty straight forward!
atm I’m messing with the FileViewerController.php and fumbling around with a new function:

    /**
     * Output image with pretty url
     * @access public
     */
    public function imagePrettyUrl()
    {
        try{
            $file = $this->getFile();
            $this->response->withContentType($this->helper->file->getImageMimeType($file['name']));
            $this->response->send();
            $this->objectStorage->output($file['path']);
        } catch (ObjectStorageException $e) {
            $this->logger->error($e->getMessage());
        }
    }

no luck yet…

hmm interesting… there doesn’t seem to be any ‘public access’ to task ‘attachments’… so if your’re trying to get an attachment via a url (and not via the json api ) then you’d need to pass some kind of credentials.

If you wanted to get an image attachment via the json api and view it or download it; is that even possible? and if so how? By default it appears to return a redundant string (quite possibly user error…)

Sorry, but it’s not a browser thing, there is as specification for a URL.

       userinfo        host      port
        ┌──┴───┐ ┌──────┴──────┐ ┌┴┐
https://john.doe@www.example.com:123/forum/q/?tag=networking#top
└─┬─┘   └───────────┬──────────────┘└┬──────┘ └──┬──────────┘└┬┘
scheme          authority           path        query      fragment

Any piece of software should be able to deal with it.

  • yes I believe it’s a permissions thing…

Yes, I think you’re right. I just wanted to help. :slightly_smiling_face:

no worries, thank you for the support!!

I’m going back to the json route due to permissions

i havent quite figured out what you are trying to accomplish

1 Like

hello Creecros!

I’m trying to view and/or save task attachments via the JSON api