pcloud-sdk-java
pcloud-sdk-java copied to clipboard
path is null (not present) if folder ID isn't 0 when calling listfolder / stat
When calling either listfolder
or stat
according to the documentation the metadata
should include the path
to the file or folder:
{
"result": 0,
"metadata": {
"ismine": true,
"id": "f1729212",
"created": "Wed, 02 Oct 2013 14:29:11 +0000",
"modified": "Wed, 02 Oct 2013 14:29:11 +0000",
"hash": 10681749967730527559,
"isshared": false,
"isfolder": false,
"category": 1,
"parentfolderid": 0,
"icon": "image",
"fileid": 1729212,
"height": 600,
"width": 900,
"path": "\/Simple image.jpg",
"name": "Simple image.jpg",
"contenttype": "image\/jpeg",
"size": 73269,
"thumb": true
}
}
-
stat
: https://docs.pcloud.com/methods/file/stat.html -
listfolder
: https://docs.pcloud.com/methods/folder/listfolder.html - Metadata: https://docs.pcloud.com/structures/metadata.html
However, the API is only returning path
when the calling listfolder
with RemoteFolder.ROOT_FOLDER_ID
:
{
"metadata": {
"path": "/",
"name": "/",
"created": "Sun, 05 Jul 2020 04:31:40 +0000",
"ismine": true,
"thumb": false,
"modified": "Sun, 05 Jul 2020 04:31:40 +0000",
"id": "d0",
"isshared": false,
"icon": "folder",
"isfolder": true,
"folderid": 0,
"contents": [
{
"name": "AndroidTest",
"created": "Tue, 16 Mar 2021 15:49:19 +0000",
"ismine": true,
"thumb": false,
"modified": "Sat, 20 Mar 2021 13:48:14 +0000",
"comments": 0,
"id": "d546891853",
"isshared": false,
"icon": "folder",
"isfolder": true,
"parentfolderid": 0,
"folderid": 546891853,
},
[..]
]
}
}
listfolder
of non root folderid:
{
"metadata": {
"name": "AndroidTest",
"created": "Tue, 16 Mar 2021 15:49:19 +0000",
"ismine": true,
"thumb": false,
"modified": "Sat, 20 Mar 2021 13:48:14 +0000",
"comments": 0,
"id": "d546891853",
"isshared": false,
"icon": 20,
"isfolder": true,
"parentfolderid": 0,
"folderid": 546891853,
"contents": [
{
"name": "TestVault",
"created": "Tue, 16 Mar 2021 21:17:47 +0000",
"ismine": true,
"thumb": false,
"modified": "Tue, 16 Mar 2021 21:35:09 +0000",
"comments": 0,
"id": "d547917979",
"isshared": false,
"icon": 20,
"isfolder": true,
"parentfolderid": 546891853,
"folderid": 547917979
},
[..]
]
}
}
I already prepared exposing path
and would have opened a PR but if this is the inteded behaviour, my PR would be pointless.
EDIT
Just realized that it is only returend when actually calling listfolder
/ stat
with path
.
Is this something you might be able to provide also when calling with ID
s?
Background: We are keeping track of the path of a file or folder. However, we cannot validate if the path is still valid, e.g. when a folder is renamed outside of our app. This is because we can still fetch the file / folder with the ID although its path has changed.
@mjenny the behavior is intended, using fileid/folderid is much more efficient. Paths require validation and extra operations on the backend so are generated for individual files when metadata-returning API calls are done on the assumption that the caller is working with paths. I can consult with someone from the API team to gather their opinion on the topic and will write back.
@georgi-neykov-hub thank you for the clarification.
We probably need to switch to paths since we don't know when a folder / file is renamed remotely outside of our app. Using fileId
or folderId
will still give us the information but since we keep track of the path we are expecting the file or folder to be in the same place as before.
That's why I opened the PR #17 to allow the usage of path
for more operations.
Or do you see any other way?
Do you want to keep this issue open and consult with the API team?