You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
sbrownnw
2 years agoExplorer | Level 4
restored folders and files have different ids than their originally added entities
given dropbox UI has no folders or files in it when I create a subfolder and add file1 to the subfolder and add file2 to the subfolder and note the ids for the new subfolder and two new files an...
- 2 years ago
In the "restore file1" step, you're only restoring the file itself, not the original folder. When adding or restoring a file, if a parent path component (the folder, in this case) doesn't already exist, it will be automatically created. That automatically created folder is a new folder, not a restored folder (and it may or may not be at the same path as the original parent folder, e.g., since you can restore a file to a different location).
As for the file ID of the restored file itself, I would expect that to be the same, and it is in my testing. Here's an example I just ran through:
curl -X POST https://api.dropboxapi.com/2/files/create_folder_v2 \ --header 'Authorization: Bearer <ACCESS_TOKEN>' \ --header 'Content-Type: application/json' \ --data '{"path":"/test_691719_folder"}' # { # "metadata": { # "name": "test_691719_folder", # "path_lower": "/test_691719_folder", # "path_display": "/test_691719_folder", # "id": "id:25N5ksooX-sAAAAAAAQyqA" # } # } curl -X POST https://content.dropboxapi.com/2/files/upload \ --header 'Authorization: Bearer <ACCESS_TOKEN>' \ --header 'Content-Type: application/octet-stream' \ --header 'Dropbox-API-Arg: {"path":"/test_691719_folder/test_691719_file"}' \ --data-binary @'test.txt' # { # "name": "test_691719_file", # "path_lower": "/test_691719_folder/test_691719_file", # "path_display": "/test_691719_folder/test_691719_file", # "id": "id:25N5ksooX-sAAAAAAAQyqQ", # "client_modified": "2023-06-14T18:42:28Z", # "server_modified": "2023-06-14T18:42:29Z", # "rev": "5fe1b50581a7c021eccc7", # "size": 27, # "is_downloadable": true, # "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75" # } curl -X POST https://api.dropboxapi.com/2/files/delete_v2 \ --header 'Authorization: Bearer <ACCESS_TOKEN>' \ --header 'Content-Type: application/json' \ --data '{"path":"/test_691719_folder"}' # { # "metadata": { # ".tag": "folder", # "name": "test_691719_folder", # "path_lower": "/test_691719_folder", # "path_display": "/test_691719_folder", # "id": "id:25N5ksooX-sAAAAAAAQyqA" # } # } curl -X POST https://api.dropboxapi.com/2/files/restore \ --header 'Authorization: Bearer <ACCESS_TOKEN>' \ --header 'Content-Type: application/json' \ --data '{"path":"/test_691719_folder/test_691719_file","rev":"5fe1b50581a7c021eccc7"}' # { # "name": "test_691719_file", # "path_lower": "/test_691719_folder/test_691719_file", # "path_display": "/test_691719_folder/test_691719_file", # "id": "id:25N5ksooX-sAAAAAAAQyqQ", # "client_modified": "2023-06-14T18:42:28Z", # "server_modified": "2023-06-14T18:43:47Z", # "rev": "5fe1b5501cafb021eccc7", # "size": 27, # "is_downloadable": true, # "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75" # } curl -X POST https://api.dropboxapi.com/2/files/get_metadata \ --header 'Authorization: Bearer <ACCESS_TOKEN>' \ --header 'Content-Type: application/json' \ --data '{"path":"/test_691719_folder"}' # { # ".tag": "folder", # "name": "test_691719_folder", # "path_lower": "/test_691719_folder", # "path_display": "/test_691719_folder", # "id": "id:25N5ksooX-sAAAAAAAQyrA" # } curl -X POST https://api.dropboxapi.com/2/files/get_metadata \ --header 'Authorization: Bearer <ACCESS_TOKEN>' \ --header 'Content-Type: application/json' \ --data '{"path":"/test_691719_folder/test_691719_file"}' # { # ".tag": "file", # "name": "test_691719_file", # "path_lower": "/test_691719_folder/test_691719_file", # "path_display": "/test_691719_folder/test_691719_file", # "id": "id:25N5ksooX-sAAAAAAAQyqQ", # "client_modified": "2023-06-14T18:42:28Z", # "server_modified": "2023-06-14T18:43:47Z", # "rev": "5fe1b5501cafb021eccc7", # "size": 27, # "is_downloadable": true, # "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75" # }
If something's not working properly for you though, please share the steps/code to reproduce the issue and show us the unexpected output or error so we can look into it.
Greg-DB
2 years agoDropbox Staff
In the "restore file1" step, you're only restoring the file itself, not the original folder. When adding or restoring a file, if a parent path component (the folder, in this case) doesn't already exist, it will be automatically created. That automatically created folder is a new folder, not a restored folder (and it may or may not be at the same path as the original parent folder, e.g., since you can restore a file to a different location).
As for the file ID of the restored file itself, I would expect that to be the same, and it is in my testing. Here's an example I just ran through:
curl -X POST https://api.dropboxapi.com/2/files/create_folder_v2 \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{"path":"/test_691719_folder"}'
# {
# "metadata": {
# "name": "test_691719_folder",
# "path_lower": "/test_691719_folder",
# "path_display": "/test_691719_folder",
# "id": "id:25N5ksooX-sAAAAAAAQyqA"
# }
# }
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Content-Type: application/octet-stream' \
--header 'Dropbox-API-Arg: {"path":"/test_691719_folder/test_691719_file"}' \
--data-binary @'test.txt'
# {
# "name": "test_691719_file",
# "path_lower": "/test_691719_folder/test_691719_file",
# "path_display": "/test_691719_folder/test_691719_file",
# "id": "id:25N5ksooX-sAAAAAAAQyqQ",
# "client_modified": "2023-06-14T18:42:28Z",
# "server_modified": "2023-06-14T18:42:29Z",
# "rev": "5fe1b50581a7c021eccc7",
# "size": 27,
# "is_downloadable": true,
# "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75"
# }
curl -X POST https://api.dropboxapi.com/2/files/delete_v2 \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{"path":"/test_691719_folder"}'
# {
# "metadata": {
# ".tag": "folder",
# "name": "test_691719_folder",
# "path_lower": "/test_691719_folder",
# "path_display": "/test_691719_folder",
# "id": "id:25N5ksooX-sAAAAAAAQyqA"
# }
# }
curl -X POST https://api.dropboxapi.com/2/files/restore \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{"path":"/test_691719_folder/test_691719_file","rev":"5fe1b50581a7c021eccc7"}'
# {
# "name": "test_691719_file",
# "path_lower": "/test_691719_folder/test_691719_file",
# "path_display": "/test_691719_folder/test_691719_file",
# "id": "id:25N5ksooX-sAAAAAAAQyqQ",
# "client_modified": "2023-06-14T18:42:28Z",
# "server_modified": "2023-06-14T18:43:47Z",
# "rev": "5fe1b5501cafb021eccc7",
# "size": 27,
# "is_downloadable": true,
# "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75"
# }
curl -X POST https://api.dropboxapi.com/2/files/get_metadata \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{"path":"/test_691719_folder"}'
# {
# ".tag": "folder",
# "name": "test_691719_folder",
# "path_lower": "/test_691719_folder",
# "path_display": "/test_691719_folder",
# "id": "id:25N5ksooX-sAAAAAAAQyrA"
# }
curl -X POST https://api.dropboxapi.com/2/files/get_metadata \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{"path":"/test_691719_folder/test_691719_file"}'
# {
# ".tag": "file",
# "name": "test_691719_file",
# "path_lower": "/test_691719_folder/test_691719_file",
# "path_display": "/test_691719_folder/test_691719_file",
# "id": "id:25N5ksooX-sAAAAAAAQyqQ",
# "client_modified": "2023-06-14T18:42:28Z",
# "server_modified": "2023-06-14T18:43:47Z",
# "rev": "5fe1b5501cafb021eccc7",
# "size": 27,
# "is_downloadable": true,
# "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75"
# }
If something's not working properly for you though, please share the steps/code to reproduce the issue and show us the unexpected output or error so we can look into it.
- sbrownnw2 years agoExplorer | Level 4
I see, the folder being created after the file being restored was causing the failure I was seeing. Yes, you are correct, the folder is a different entity (not sure why, with a different Id) but the restored file has the same Id as the originally added one.
About Discuss Dropbox Developer & API
Make connections with other developers
795 PostsLatest Activity: 7 days agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!