ファイルのコピーを作成します。
12345
ファイルを表す一意の識別子。
ファイルIDを確認するには、ウェブアプリケーションでファイルにアクセスして、URLからIDをコピーします。たとえば、URLがhttps://*.app.box.com/files/123
の場合、file_id
は123
です。
id,type,name
応答に含める属性のカンマ区切りリスト。このパラメータを使用すると、標準の応答には通常含まれないフィールドをリクエストできます。
このパラメータを指定すると、明示的に指定しない限り標準フィールドは応答に含まれず、リクエストしたフィールドのほかには、簡易版レプリゼンテーションのフィールドしか返されないことに注意してください。
FileCopy.txt
255
コピーされたファイルの新しい名前(省略可)。
ファイル名にはいくつかの制約があります。印刷不可能なASCII文字、スラッシュ、およびバックスラッシュ(/
、\
)を含む名前のほか、.
や..
のような予約済みの名前は、許可されていない文字を削除することで自動的にサニタイズされます。
ファイルのコピー先となるフォルダ。
0
ファイルのコピー先となるフォルダのID。
0
コピーする特定のファイルバージョンのID(省略可)
If-None-Match
ヘッダーがファイルの現在のetag
値と一致する場合は、空の応答を返します。これは、ファイルが前回リクエストされたときから変更されていないことを示します。
一部のパラメータが指定されていないか無効な場合はエラーを返します。
bad_request
- パラメータが指定されていない場合に返されます。ソースファイルまたは宛先フォルダのどちらも見つからないか、認証済みユーザーがどちらにもアクセスできない場合はエラーを返します。
not_found
- 認証済みユーザーがソースファイルまたは宛先フォルダにアクセスできない場合に返されますoperation_blocked_temporary
: 別の移動、コピー、削除、または復元操作が進行中であるために宛先フォルダまたは元のフォルダがロックされている場合に返されます。
操作は後で再試行することができます。
item_name_in_use
: 同じ名前のフォルダがすでに存在する場合に返されます。予期しないクライアントエラー。
curl -X POST https://api.box.com/2.0/files/12345/copy \
-H 'Authorization: Bearer <ACCESS_TOKEN>" '
-H 'Content-Type: application/json" '
-d '{
"parent": {
"id": "123"
}
}'
string fileId = "11111";
string destinationFolderId = "22222";
var requestParams = new BoxFileRequest()
{
Id = fileId,
Parent = new BoxRequestEntity()
{
Id = destinationFolderId
}
};
BoxFile fileCopy = await client.FilesManager.CopyAsync(requestParams);
// Copy a file into the user's root folder
BoxFolder rootFolder = BoxFolder.getRootFolder(api);
BoxFile file = new BoxFile(api, "id");
BoxFile.Info copiedFileInfo = file.copy(rootFolder, "New Name");
file_id = '11111'
destination_folder_id = '44444'
file_to_copy = client.file(file_id)
destination_folder = client.folder(destination_folder_id)
file_copy = file_to_copy.copy(destination_folder)
print('File "{0}" has been copied into folder "{1}"'.format(file_copy.name, file_copy.parent.name))
var fileID = '11111';
var destinationFolderID = '22222';
client.files.copy(fileID, destinationFolderID)
.then(fileCopy => {
/* fileCopy -> {
type: 'file',
id: '11112',
file_version:
{ type: 'file_version',
id: '99999',
sha1: '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' },
sequence_id: '0',
etag: '0',
sha1: '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33',
name: 'My File.pdf',
description: '',
size: 68431,
path_collection:
{ total_count: 1,
entries:
[ { type: 'folder',
id: '0',
sequence_id: null,
etag: null,
name: 'All Files' },
{ type: 'folder',
id: '22222',
sequence_id: null,
etag: null,
name: 'Personal Files' } ] },
created_at: '2017-05-16T15:18:02-07:00',
modified_at: '2017-05-16T15:18:02-07:00',
trashed_at: null,
purged_at: null,
content_created_at: '2017-05-16T15:18:02-07:00',
content_modified_at: '2017-05-16T15:18:02-07:00',
created_by:
{ type: 'user',
id: '33333',
name: 'Test User',
login: 'test@example.com' },
modified_by:
{ type: 'user',
id: '33333',
name: 'Test User',
login: 'test@example.com' },
owned_by:
{ type: 'user',
id: '33333',
name: 'Test User',
login: 'test@example.com' },
shared_link: null,
parent:
{ type: 'folder',
id: '22222',
sequence_id: null,
etag: null,
name: 'Personal Files' }
item_status: 'active' }
*/
});
client.files.copy(fileId: "11111", parentId: "0") { (result: Result<File, BoxSDKError>) in
guard case let .success(copiedFile) = result else {
print("Error copying file")
return
}
print("Copied file \(copiedFile.name) into folder \(copiedFile.parent.name); copy has file ID \(copiedFile.id)")
}