Restores a file that has been moved to the trash.
An optional new parent ID can be provided to restore the file to in case the original folder has been deleted.
12345
The unique identifier that represents a file.
The ID for any file can be determined
by visiting a file in the web application
and copying the ID from the URL. For example,
for the URL https://*.app.box.com/files/123
the file_id
is 123
.
id,type,name
A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.
Be aware that specifying this parameter will have the effect that none of the standard fields are returned in the response unless explicitly specified, instead only fields for the mini representation are returned, additional to the fields requested.
"Restored.docx"
An optional new name for the file.
Specifies an optional ID of a folder to restore the file to when the original folder no longer exists.
Please be aware that this ID will only be used if the original folder no longer exists. Use this ID to provide a fallback location to restore the file to if the original location has been deleted.
"123"
The ID of parent item
"12346930"
The input for {user_id}
is optional. Moving to non-root folder is not allowed when {user_id}
is present. Parent folder id should be zero when {user_id}
is provided.
Returns a file object when the file has been restored.
Returns an error if the user does not have access to the folder the file is being restored to, or the user does not have permission to restore files from the trash.
Returns an error if the file is not in the trash.
Returns an error if there is an file with the same name in the folder the file is being restored to.
An unexpected client error.
curl -i -X POST "https://api.box.com/2.0/files/12345" \
-H "authorization: Bearer <ACCESS_TOKEN>"
await client.trashedFiles.restoreFileFromTrash(file.id);
client.trashed_files.restore_file_from_trash(file.id)
await client.TrashedFiles.RestoreFileFromTrashAsync(fileId: file.Id);
try await client.trashedFiles.restoreFileFromTrash(fileId: file.id)
String fileID = "125367";
String newName = "Presentation 2018 ORIGINAL.pptx";
String newParentID = "98765";
BoxTrash trash = new BoxTrash(api);
// Avoid conflicts at the original location
trash.restoreFile(fileID, newName, newParentID);
file_to_restore = client.file(file_id='11111')
restored_file = client.trash().restore_item(file_to_restore)
print(f'File ID is {restored_file.id} and name is {restored_file.name}')
var requestParams = new BoxFileRequest()
{
Name = "Name in case of conflict",
Parent = new BoxRequestEntity()
{
// File will be placed in this folder if original location no longer exists
Id = "12345"
}
};
BoxFile restoredFile = await client.FilesManager.RestoreTrashedAsync(requestParams);
client.files.restoreFromTrash(
'11111',
{
// New name in case of conflict
name: 'New Name',
// File will be placed in this folder if original location no longer exists
parent_id: '0'
})
.then(restoredFile => {
/* trashedFile -> {
type: 'file',
id: '11111',
sequence_id: '2',
etag: '2',
sha1: '4bd9e98652799fc57cf9423e13629c151152ce6c',
name: 'Screenshot_1_30_13_6_37_PM.png',
description: '',
size: 163265,
path_collection:
{ total_count: 1,
entries:
[ { type: 'folder',
id: '0',
sequence_id: null,
etag: null,
name: 'All Files' } ] },
created_at: '2013-01-30T18:43:56-08:00',
modified_at: '2013-01-30T18:44:00-08:00',
trashed_at: null,
purged_at: null,
content_created_at: '2013-01-30T18:43:56-08:00',
content_modified_at: '2013-01-30T18:44:00-08:00',
created_by:
{ type: 'user',
id: '33333',
name: 'Example User',
login: 'user@example.com' },
modified_by:
{ type: 'user',
id: '33333',
name: 'Example User',
login: 'user@example.com' },
owned_by:
{ type: 'user',
id: '33333',
name: 'Example User',
login: 'user@example.com' },
shared_link: null,
parent:
{ type: 'folder',
id: '0',
sequence_id: null,
etag: null,
name: 'All Files' },
item_status: 'active' }
*/
});
{
"id": "123456789",
"type": "file",
"content_created_at": "2012-12-12T10:53:43-08:00",
"content_modified_at": "2012-12-12T10:53:43-08:00",
"created_at": "2012-12-12T10:53:43-08:00",
"created_by": {
"id": "11446498",
"type": "user",
"login": "ceo@example.com",
"name": "Aaron Levie"
},
"description": "Contract for Q1 renewal",
"etag": "1",
"file_version": {
"id": "12345",
"type": "file_version",
"sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc"
},
"item_status": "active",
"modified_at": "2012-12-12T10:53:43-08:00",
"modified_by": {
"id": "11446498",
"type": "user",
"login": "ceo@example.com",
"name": "Aaron Levie"
},
"name": "Contract.pdf",
"owned_by": {
"id": "11446498",
"type": "user",
"login": "ceo@example.com",
"name": "Aaron Levie"
},
"parent": {
"id": "12345",
"type": "folder",
"etag": "1",
"name": "Contracts",
"sequence_id": "3"
},
"path_collection": {
"entries": [
{
"etag": "1",
"id": "12345",
"type": "folder",
"name": "Contracts",
"sequence_id": "3"
}
],
"total_count": 1
},
"purged_at": "null",
"sequence_id": "3",
"sha1": "85136C79CBF9FE36BB9D05D0639C70C265C18D37",
"shared_link": "null",
"size": 629644,
"trashed_at": "null"
}