Box: フォルダ削除 (Box: Delete Folder)
この工程は、Box 上のフォルダを削除します。一度に複数の削除が可能です。
Configs:共通設定
  • 工程名
  • メモ
Configs
  • C1: OAuth2 設定 *
  • C2: 削除するフォルダ ID (1 行 1 ID) *

Notes

  • フォルダ ID は、URL に含まれています。 https:// {sub-domain}.app.box.com/folder/(Folder ID)
  • Box のリフレッシュトークンには、期限があります。期限を超えないよう、定期的に利用する必要があります。(Box: トークンおよびURLの有効期限)

Capture

See also

Script (click to open)
  • 下記のスクリプトを記述した XML ファイルをダウンロードできます
    • box-folder-delete.xml (C) Questetra, Inc. (MIT License)
    • Professional をご利用であればファイルの内容を改変することでオリジナルのアドオンとして活用できます
main();
function main(){
  const folderIds = engine.findDataByNumber(configs.get("FolderIdsItem"));
  if (folderIds === "" ||folderIds === null){
    throw "Folder IDs aren't set.";
  }
  let linesArray = folderIds.split("\n");
  linesArray = linesArray.filter(lines => lines !== ""); // 空文字列を削除
  if (linesArray.length === 0) {
    throw "Folder IDs aren't set.";
  }
  const numOfLines = linesArray.length;
  if (numOfLines > httpClient.getRequestingLimit()){
  	throw "Number of Folder IDs is over the limit."
  }
  const oauth2 = configs.get("OAuth2");
  for (let i = 0; i < numOfLines; i++){
    deleteFolder(oauth2, linesArray[i])
  }
}
function deleteFolder(oauth2, folderId) {
  const url = `https://api.box.com/2.0/folders/${folderId}`;
  let response = httpClient.begin()
    .authSetting(oauth2)
    .queryParam("recursive","true")
    .delete(url);
  const status = response.getStatusCode();
  const responseTxt = response.getResponseAsString();
  engine.log(`status: ${status}`);
  if (status >= 300) {
    engine.log(responseTxt)
    throw `Failed to delete Folder ID:${folderId}`;
  }else{
    engine.log(`Succeeded to delete Folder ID:${folderId}`);
  }
}

%d