dng
September 17, 2022, 11:56am
1
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
alfredb
September 17, 2022, 1:22pm
2
Yes, at least if you are certain that db93e016c2961cf5c3571ee5975418a6f2f28fc7 indeed IS a PNG file.
dng
September 22, 2022, 11:56am
3
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…
alfredb
September 22, 2022, 12:02pm
4
I think I will be downloaded with the correct content-type, no need to append something.
dng
September 22, 2022, 12:11pm
5
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,
alfredb
September 22, 2022, 12:26pm
6
Well, then you have both components you need:
server-url + path + extension from name
dng
September 22, 2022, 12:28pm
7
alfredb
September 22, 2022, 12:36pm
9
OK, I see. This doesn’t work.
dng
September 22, 2022, 12:37pm
10
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”
},
alfredb
September 22, 2022, 12:39pm
11
You have to find a way, that python can deal with a totally legal URL.
dng
September 22, 2022, 12:41pm
12
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
alfredb
September 22, 2022, 2:04pm
13
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.
dng
September 22, 2022, 2:48pm
14
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…
dng
September 22, 2022, 4:02pm
15
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…)
dng
September 22, 2022, 4:09pm
16
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…
alfredb
September 22, 2022, 7:02pm
17
Yes, I think you’re right. I just wanted to help.
dng
September 23, 2022, 2:02am
18
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
dng
September 23, 2022, 4:12am
20
hello Creecros!
I’m trying to view and/or save task attachments via the JSON api