日本時間5月16日のContent Cloud Summitで、カスタムアプリにBox AI APIを活用する方法を紹介します。

詳細を表示

ファイルの復元

ガイド ごみ箱 ファイルの復元

ファイルの復元

ごみ箱に移動されたが削除されていないファイルを復元するには、/files/:file_idエンドポイントにPOSTリクエストを送信します。これにより、ファイルがまだ使用可能であれば元のフォルダに戻されます。または、オプションとしてparentフォルダを指定することもできます。

cURL
curl -i -X POST "https://api.box.com/2.0/files/12345" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
.NET
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);
Java
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);
Python
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}')
Node
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' }
		*/
	});