Dropbox Upload

Uploads the file specified by File type data item to the specified directory of Dropbox, and stores its communication log in a String type data item

    A. Set Key (access token) for Dropbox Access (64 letters)Single-line inputRequired
    B. Select STRING/SELECT for Directory on Dropbox (e.g. "/a/b/")Data selectString(single line)orSelect(radio/select/search)Required
    C. Select FILE DATA for UploadData selectFileRequired
    X. Select STRING DATA for Access Log (update)Data selectString(multiple line)
    -variable namevariable label
    Aconf_AccessTokenSet Key (access token) for Dropbox Access (64 letters)
    Bconf_DataIdBSelect STRING/SELECT for Directory on Dropbox (e.g. "/a/b/")
    Cconf_DataIdCSelect FILE DATA for Upload
    Xconf_DataIdXSelect STRING DATA for Access Log (update)
    // Upload to Dropbox via DropboxAPI v1 (ver. 20161005)
    // (c) 2016, Questetra, Inc. (the MIT License)
    
    //// == 工程コンフィグの参照 / Config Retrieving ==
    var accessToken = configs.get( "conf_AccessToken" );
    var dataIdB = configs.get( "conf_DataIdB" ); // (returns Number)
    var dataIdC = configs.get( "conf_DataIdC" ); // (returns Number)
    var dataIdX = configs.get( "conf_DataIdX" ); // (returns Number)
    
    //// == ワークフローデータの参照 / Data Retrieving ==
    var dirPath = "";
    if( data.get( dataIdB ) instanceof java.util.ArrayList ){
      dirPath = data.get( dataIdB ).get(0).getValue() + "";
    }else if( data.get( dataIdB ) instanceof java.lang.String ){
      dirPath = data.get( dataIdB ) + "";
    }
    var files = data.get( dataIdC );
    
    //// == 演算 / Calculating ==
    var accessLog = "";
    var responseJson = "";
    for( var i = 0; i < files.size(); i++  ){
      var uri = "https://content.dropboxapi.com/1/files_put/auto";
      uri += dirPath;
      uri += files.get(i).getName() + "";
      var response = httpClient.begin()
        .bearer( accessToken )
        .queryParam( 'overwrite', false )
        .body( files.get(i) )
        .put( uri );
      accessLog += "---PUT request--- " + response.getStatusCode() + "\n";
      responseJson += response.getResponseAsString() + "\n";
    }
    // for Debug
    accessLog += responseJson + "\n";
    
    //// == ワークフローデータへの代入 / Data Updating ==
    if( dataIdX !== "" ){
      retVal.put( dataIdX, accessLog );
    }
    

    • B’: Dropbox directory name stored in the Data Item selected at config B
    • C’: File stored in the Data Item selected at config C
    • File C’ will be uploaded to the specified directory B’
    • The communication logs will be stored in the Data Item selected at config X
    • It is required to register Apps at Dropbox Platform in advance
    • If the specified directory does not exist, a new directory will be automatically generated
    • When the filename conflicts, the file will be renamed and saved (e.g.:“example (1).JPG”)
    • Since Dropbox OAuth does not refresh Access Token, it performs communications in a method not using [OAuth 2.0 setting] in this automated step