コレクションからの項目の削除
コレクションからの項目の削除
コレクションから項目を削除するには、その特定のタイプの項目に対してPUT
エンドポイントを呼び出し、削除するコレクションのIDが含まれていない、コレクションIDのリストを渡します。
コレクションからのファイルの削除
コレクションにファイルを追加するには、PUT /files/:id
APIを呼び出し、コレクションIDの空の配列を渡します。
cURL
curl -X PUT https://api.box.com/2.0/files/12345 \
-H 'Authorization: Bearer <ACCESS_TOKEN>" '
-H 'Content-Type: application/json" '
-d '{
"collections": []
}'
Java
BoxFile file = new BoxFile(api, "id");
BoxFile.Info info = file.getInfo("collections");
ArrayList<BoxCollection> collections = new ArrayList<BoxCollection>();
for (BoxCollection.Info info : info.getCollections(api)) {
// Include every existing collection except for favorites to remove the file
// from the favorites collection.
if (!info.getCollectionType().equals("favorites")) {
collections.add(info.getResource());
}
}
file.setCollections(collections.toArray());
Python
collection = client.collection(collection_id='12345')
updated_file = client.file(file_id='11111').remove_from_collection(collection)
print('File "{0}" removed from collection!'.format(updated_file.name))
Node
client.files.removeFromCollection('87263', '235747', callback);
iOS
client.files.removeFromFavorites(fileId: "11111") { (result: Result<Void, BoxSDKError>) in
guard case .success = result else {
print("Error removing file from favorites")
return
}
print("File removed from favorites")
}
コレクションからのフォルダの削除
コレクションにフォルダを追加するには、PUT /folders/:id
APIを呼び出し、コレクションIDの空の配列を渡します。
コレクションからのウェブリンクの削除
コレクションにウェブリンクを追加するには、PUT /web_links/:id
APIを呼び出し、コレクションIDの空の配列を渡します。