ファイルを復元

post
https://api.box.com/2.0
/files/:file_id

ごみ箱に移動されたファイルを復元します。

元のフォルダが削除されている場合にフォルダの復元先となる新しい親ID (省略可) を指定することができます。

リクエスト

bearer [ACCESS_TOKEN]
application/json

パスパラメータ

stringパス内必須
12345

ファイルを表す一意の識別子。

ファイルIDを確認するには、ウェブアプリケーションでファイルにアクセスして、URLからIDをコピーします。たとえば、URLがhttps://*.app.box.com/files/123の場合、file_id123です。

クエリパラメータ

string arrayクエリ内省略可能
id,type,name

レスポンスに含める属性のコンマ区切りリスト。このパラメータを使用すると、標準のレスポンスには通常含まれないフィールドをリクエストできます。

このパラメータを指定すると、明示的に指定しない限り標準フィールドはレスポンスに含まれず、リクエストしたフィールドのほかには、Mini版の表示のフィールドしか返されないことに注意してください。

リクエスト本文

string本文内省略可能
"Restored.docx"

ファイルの新しい名前 (省略可)。

object本文内

元のフォルダがすでに存在しない場合にファイルの復元先となるフォルダのID (省略可) を指定します。

このIDは、元のフォルダがすでに存在しない場合にのみ使用されることに注意してください。このIDは、元の場所が削除されている場合にファイルの復元先となるフォールバックの場所を指定します。

string本文内省略可能
"123"

親項目のID

レスポンス

ファイルが復元されたときにファイルオブジェクトを返します。

ファイルの復元先フォルダに対してユーザーがアクセス権限を持っていない場合、またはごみ箱からファイルを復元する権限を持っていない場合は、エラーを返します。

ファイルがごみ箱内にない場合は、エラーを返します。

ファイルの復元先フォルダに同じ名前のファイルが存在する場合は、エラーを返します。

予期しないクライアントエラー。

post
ファイルを復元
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

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' }
		*/
	});

レスポンスの例

{
  "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": [
      {
        "id": "12345",
        "etag": "1",
        "type": "folder",
        "sequence_id": "3",
        "name": "Contracts"
      }
    ],
    "total_count": 1
  },
  "purged_at": "null",
  "sequence_id": "3",
  "sha1": "85136C79CBF9FE36BB9D05D0639C70C265C18D37",
  "shared_link": "null",
  "size": 629644,
  "trashed_at": "null"
}