Adobe PDF Services #ASSET: アップロード
Adobe PDF Services #ASSET: Upload
ASSET(各種素材ファイル)を PDF Services 用の内部ストレージにアップロードします。素材ファイルの AssetID は、下流工程における PDF Services 操作にて活用されます。
Configs for this Auto Step
- AuthzConfU1
- U1: PDF-SERVICES-API Client ID 設定を選択してください(認証設定>直接指定) *
- AuthzConfU2
- U2: PDF-SERVICES-API Client Secret 設定を選択してください(認証設定>直接指定) *
- SelectConfA1
- A1: アップロード対象ファイル(Asset)が格納されているファイル型データ項目を選択してください *
- SelectConfB1
- B1: AssetID が格納される文字列型データ項目を選択してください (更新) *
- StrConfU3
- U3: 指定リージョンで処理させたい場合 {regionCode} をセットしてください(”ew1″)#{EL}
Script (click to open)
// GraalJS standard mode Script Script (engine type: 3)
// cf. 'engine type: 2': "GraalJS Nashorn compatible mode" (renamed from "GraalJS" at 20230526)
//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){
////// == Config Retrieving / 工程コンフィグの参照 ==
const strAuthzId = configs.get( "AuthzConfU1" ); /// REQUIRED
engine.log( " AutomatedTask Config: Authz ID: " + strAuthzId );
const strClientId = httpClient.getOAuth2Token( strAuthzId );
if ( strClientId === "" ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {U1: ClientId} is empty \n" );
}
const strAuthzSecret = configs.get( "AuthzConfU2" ); /// REQUIRED
engine.log( " AutomatedTask Config: Authz SECRET: " + strAuthzSecret );
const strClientSecret = httpClient.getOAuth2Token( strAuthzSecret );
if ( strClientSecret === "" ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {U2: ClientSecret} is empty \n" );
}
const strRegionCode = configs.get( "StrConfU3" ); // Not Required
let strRegionPostfix = strRegionCode !== "" ? ("-" + strRegionCode) : "";
engine.log( " AutomatedTask Config: strRegionPostfix: " + strRegionPostfix );
// https://developer.adobe.com/document-services/docs/overview/pdf-services-api/howtos/service-region-configuration-for-apis/
const filesPocketUpload = configs.getObject( "SelectConfA1" ); /// REQUIRED
let filesUpload = engine.findData( filesPocketUpload ); // java.util.ArrayList
if( filesUpload === null ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {A1: File} must be non-empty \n" );
}
engine.log( " AutomatedTask Config: #of FILES: " + filesUpload.size() );
engine.log( " AutomatedTask Config: File Uploaded: " + filesUpload.get(0).getName() );
const strPocketAssetId = configs.getObject( "SelectConfB1" ); /// REQUIRED
////// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)
////// == Calculating / 演算 ==
//// Adobe Developer > PDF Services API > Generate Token
//// Generate access token to perform PDF Services operations
//// https://developer.adobe.com/document-services/docs/apis/#tag/Generate-Token
/// prepare request1
let request1Uri = "https://pdf-services" + strRegionPostfix + ".adobe.io/token";
let request1 = httpClient.begin(); // HttpRequestWrapper
/// prepare application/x-www-form-urlencoded
request1 = request1.formParam ( "client_id", strClientId );
request1 = request1.formParam ( "client_secret", strClientSecret );
/// try request1
const response1 = request1.post( request1Uri ); // HttpResponseWrapper
engine.log( " AutomatedTask ApiRequest1 Start: " + request1Uri );
const response1Code = response1.getStatusCode() + ""; // JavaNum to string
const response1Body = response1.getResponseAsString();
engine.log( " AutomatedTask ApiResponse1 Status: " + response1Code );
if( response1Code !== "200"){
throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
response1Code + "\n" + response1Body + "\n" );
}
/* engine.log( response1Body ); // debug
{
"access_token":"xxxxxxxxxx975yyyyyyyyyy",
"token_type":"bearer",
"expires_in":86399
}
*/
/// parse response1 (OAuth Server-to-Server)
const response1Obj = JSON.parse( response1Body );
const strAccessToken = response1Obj.access_token;
//// Adobe Developer > PDF Services API > Assets
//// Get upload pre-signed URI.
//// https://developer.adobe.com/document-services/docs/apis/#tag/Assets/operation/asset.uploadpresignedurl
/// prepare request2
let request2Uri = "https://pdf-services" + strRegionPostfix + ".adobe.io/assets";
let request2 = httpClient.begin(); // HttpRequestWrapper
/// prepare header parameters
request2 = request2.bearer ( strAccessToken );
request2 = request2.header ( "x-api-key", strClientId );
/// prepare application/json
let strJson = {};
strJson.mediaType = filesUpload.get(0).getContentType();
request2 = request2.body ( JSON.stringify( strJson ), "application/json" );
engine.log( " AutomatedTask ApiRequest2 Content-Type: " + filesUpload.get(0).getContentType() );
/// try request2
const response2 = request2.post( request2Uri ); // HttpResponseWrapper
engine.log( " AutomatedTask ApiRequest2 Start: " + request2Uri );
const response2Code = response2.getStatusCode() + ""; // JavaNum to string
const response2Body = response2.getResponseAsString();
engine.log( " AutomatedTask ApiResponse2 Status: " + response2Code );
if( response2Code !== "200"){
throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
response2Code + "\n" + response2Body + "\n" );
}
/* engine.log( response2Body ); // debug
{
"uploadUri":"https://dcplatformstorageservice-prod-us-east-1.s3-accelerate.amazonaws.com/xxxxx819yyyyy",
"assetID":"urn:aaid:AS:UE1:xxxxxyyyyyzzzzzwwwwwXXXXXYYYYYZZZZZW"
}
*/
/// parse response2 (Upload URI)
const response2Obj = JSON.parse( response2Body );
const strUploadUri = response2Obj.uploadUri;
const strAssetId = response2Obj.assetID;
//// PUT API call
//// https://developer.adobe.com/document-services/docs/overview/pdf-services-api/gettingstarted/
/// prepare request3
let request3Uri = strUploadUri;
let request3 = httpClient.begin(); // HttpRequestWrapper
request3 = request3.body ( filesUpload.get(0), filesUpload.get(0).getContentType() );
/// try request3
const response3 = request3.put ( request3Uri ); // HttpResponseWrapper
engine.log( " AutomatedTask ApiRequest3 Start: " + request3Uri );
const response3Code = response3.getStatusCode() + ""; // JavaNum to string
const response3Body = response3.getResponseAsString();
engine.log( " AutomatedTask ApiResponse3 Status: " + response3Code );
if( response3Code !== "200"){
throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
response3Code + "\n" + response3Body + "\n" );
}
/* engine.log( response3Body ); // debug (empty responce)
*/
////// == Data Updating / ワークフローデータへの代入 ==
if( strPocketAssetId !== null ){
engine.setData( strPocketAssetId, strAssetId );
}
} //////// END "main()" /////////////////////////////////////////////////////////////////
/*
Notes:
- If you place this "Automated Step" in the Workflow diagram, the request will be automatically sent every time the process token arrives.
- A request is automatically sent to the Adobe PDF Services API server. (REST API)
- The response from the Adobe PDF Services API server is automatically parsed.
- This "Automated Step" uploads a file (Asset) from the workflow platform to the Adobe internal storage.
- Only one file can be uploaded at a time.
- Each file is automatically deleted in 24-48 hours.
- To activate a Workflow App that includes this Automated Step, "HTTP Authz Setting" is required
- Set Credentials to "Token Fixed Value" in Workflow App.
- Obtain Credentials ("Client ID" and "Client Secret") in advance.
- https://acrobatservices.adobe.com/dc-integration-creation-app-cdn/main.html?api=pdf-services-api
- Adobe Developer Console
- https://developer.adobe.com/console/projects
APPENDIX
- PDF Services:
- Essential PDF tools to store and share files online, as well as create, combine, export, organize, and fill & sign documents.
- https://helpx.adobe.com/enterprise/using/optional-services.html
- PDF Services API to automate for your document workflows
- create a PDF from a dynamic HTML report
- set a password to prevent unauthorized opening of the document
- compress it for sharing as an attachment
- extract text, tables, images and document structure to enable downstream solutions
- https://developer.adobe.com/document-services/docs/overview/#pdf-services-api-to-automate-for-your-document-workflows
- Adobe PDF Services API Free Tier
- 500 freeDocument Transactions per month. No credit card required. (asof 202306)
- https://developer.adobe.com/document-services/docs/overview/limits/#usage-limits
- Internal storage retention period
- Each ASSET is deleted after a certain period of time.
- AutomatedTask UnexpectedResponseError: 404
- `{"error":{"code":"Not Found","message":"The requested resource does not exist."}}`
Notes-ja:
- この[自動工程]をワークフロー図に配置すれば、案件が到達する度にリクエストが自動送信されます。
- Adobe PDF Services API サーバに対してリクエストが自動送出されます。(REST API通信)
- Adobe PDF Services API サーバからのレスポンスが自動保存解析されます。
- この[自動工程]は、ワークフロー基盤から Adobe 内部ストレージにファイル(Asset)をアップロードします。
- 一度にアップロードできるファイル数は、1つです。
- 各ファイルは、24~48時間で自動的に削除されます。
- この[アドオン自動工程]を含むワークフローアプリを運用するには[HTTP 認証設定]が必要です。
- Credentials はワークフローアプリの[トークン直接指定]にセットします。
- あらかじめ Credentials ("Client ID" および "Client Secret") を取得しておいてください。
- https://acrobatservices.adobe.com/dc-integration-creation-app-cdn/main.html?api=pdf-services-api
- Adobe Developer Console
- https://developer.adobe.com/console/projects
APPENDIX-ja
- PDF Servicesとは
- ファイルのオンラインでの保存、共有のほか、ドキュメントの作成、結合、書き出し、整理、入力と署名を行うための PDF 基本ツールです。
- https://helpx.adobe.com/jp/enterprise/using/optional-services.html
- Document ワークフローを自動化する PDF Services API
- 動的 HTML レポートから PDF を簡単に作成
- ドキュメントが不正に開かれないようにパスワードを設定
- 添付ファイルとして共有するために圧縮
- テキスト、表、画像、ドキュメント構造を抽出してダウンストリーム ソリューションを実現
- https://developer.adobe.com/document-services/docs/overview/#pdf-services-api-to-automate-for-your-document-workflows
- Adobe PDF Services API の無料利用枠
- 毎月500件の無料ドキュメントトランザクション。クレジットカードは必要なし。(202306現在)
- https://developer.adobe.com/document-services/docs/overview/limits/#usage-limits
- 内部ストレージの保存期間
- 各ASSETは、一定時間経過で削除されます。
- AutomatedTask UnexpectedResponseError: 404
- `{"error":{"code":"Not Found","message":"The requested resource does not exist."}}`
*/
Download
- adobe-pdf-services-asset-upload-2023.xml
- 2023-06-28 (C) Questetra, Inc. (MIT License)
(アドオン自動工程のインストールは Professional editionでのみ可能です)
Notes
- この[自動工程]をワークフロー図に配置すれば、案件が到達する度にリクエストが自動送信されます。
- Adobe PDF Services API サーバに対してリクエストが自動送出されます。(REST API通信)
- Adobe PDF Services API サーバからのレスポンスが自動保存解析されます。
- この[自動工程]は、ワークフロー基盤から Adobe 内部ストレージにファイル(Asset)をアップロードします。
- 一度にアップロードできるファイル数は、1つです。
- 各ファイルは、24~48時間で自動的に削除されます。
- この[アドオン自動工程]を含むワークフローアプリを運用するには[HTTP 認証設定]が必要です。
- Credentials はワークフローアプリの[トークン直接指定]にセットします。
- あらかじめ Credentials (“Client ID” および “Client Secret”) を取得しておいてください。
- Adobe Developer Console
Capture

Appendix
- PDF Servicesとは
- ファイルのオンラインでの保存、共有のほか、ドキュメントの作成、結合、書き出し、整理、入力と署名を行うための PDF 基本ツールです。
- https://helpx.adobe.com/jp/enterprise/using/optional-services.html
- Document ワークフローを自動化する PDF Services API
- 動的 HTML レポートから PDF を簡単に作成
- ドキュメントが不正に開かれないようにパスワードを設定
- 添付ファイルとして共有するために圧縮
- テキスト、表、画像、ドキュメント構造を抽出してダウンストリーム ソリューションを実現
- https://developer.adobe.com/document-services/docs/overview/#pdf-services-api-to-automate-for-your-document-workflows
- Adobe PDF Services API の無料利用枠
- 毎月500件の無料ドキュメントトランザクション。クレジットカードは必要なし。(202306現在)
- https://developer.adobe.com/document-services/docs/overview/limits/#usage-limits
- 内部ストレージの保存期間
- 各ASSETは、一定時間経過で削除されます。
- AutomatedTask UnexpectedResponseError: 404
{"error":{"code":"Not Found","message":"The requested resource does not exist."}}