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

詳細を表示

フォルダの復元

ガイド ごみ箱 フォルダの復元

フォルダの復元

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

cURL
curl -i -X POST "https://api.box.com/2.0/folders/4353455" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
.NET
var requestParams = new BoxFolderRequest()
{
    Name = "Name in case of conflict",
    Parent = new BoxRequestEntity()
    {
        // Folder will be placed in this parent folder if original location no longer exists
        Id = "12345" 
    }
};
BoxFolder restoredFolder = await client.FoldersManager.RestoreTrashedFolderAsync(requestParams);
Java
String folderID = "125367";
String newName = "My Documents ORIGINAL";
String newParentID = "98765";

BoxTrash trash = new BoxTrash(api);
// Avoid conflicts at the original location
trash.restoreFolder(folderID, newName, newParentID);
Python
folder_to_restore = client.folder(folder_id='22222')
restored_folder = client.trash().restore_item(folder_to_restore)
print(f'Folder ID is {restored_folder.id} and name is {restored_folder.name}')
Node
client.folders.restoreFromTrash(
	'22222',
	{
		// New name in case of conflict
		name: 'New Name',
		// Folder will be placed in this parent folder if the original parent no longer exists
		parent_id: '0'
	})
	.then(restoredFolder => {
		/* trashedFolder -> {
			type: 'folder',
			id: '22222',
			sequence_id: '1',
			etag: '1',
			name: 'Old Files',
			created_at: '2013-05-06T22:37:30-07:00',
			modified_at: '2013-05-06T22:39:08-07:00',
			description: '',
			size: 18482,
			path_collection: 
			{ total_count: 1,
				entries: 
				[ { type: 'folder',
					id: '0',
					sequence_id: null,
					etag: null,
					name: 'All Files' } ] },
			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' },
			trashed_at: null,
			purged_at: null,
			content_created_at: '2013-05-06T22:37:30-07:00',
			content_modified_at: '2013-05-06T22:39:08-07:00',
			owned_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			shared_link: null,
			folder_upload_email: null,
			parent: 
			{ type: 'folder',
				id: '0',
				sequence_id: null,
				etag: null,
				name: 'All Files' },
			item_status: 'active' }
		*/
	});

フォルダ復元の進行中は、ファイルツリーの一部がロックされます。ロックされるのは、リクエストの元のフォルダとその子孫フォルダ、および宛先フォルダです。

フォルダの復元中、ロックされているフォルダに対して、それ以外の移動、コピー、削除、復元の操作を実行することはできません。