애플리케이션 코드
사용자 지정 코드는 로컬에서 사용할 수 있는 원본 파일(source.path
)을 사용하는 콜백만 제공하면 됩니다. rendition.path
은(는) 자산 처리 요청의 최종 결과를 배치할 위치입니다. 사용자 지정 응용 프로그램은 콜백을 사용하여 로컬에서 사용 가능한 소스 파일을 전달된 이름을 사용하여 렌디션 파일로 변환합니다(rendition.path
). 사용자 지정 응용 프로그램에서 렌디션을 만들려면 rendition.path
에 작성해야 합니다.
const { worker } = require('@adobe/asset-compute-sdk');
const fs = require('fs').promises;
// worker() is the entry point in the SDK "framework".
// The asynchronous function defined is the rendition callback.
exports.main = worker(async (source, rendition) => {
// Tip: custom worker parameters are available in rendition.instructions.
console.log(rendition.instructions.name); // should print out `rendition.jpg`.
// Simplest example: copy the source file to the rendition file destination so as to transfer the asset as is without processing.
await fs.copyFile(source.path, rendition.path);
});
소스 파일 다운로드
사용자 정의 응용 프로그램은 로컬 파일만 처리합니다. Asset compute SDK에서 원본 파일 다운로드를 처리합니다.
렌디션 만들기
SDK는 각 변환에 대해 비동기 변환 콜백 함수를 호출합니다.
콜백 함수에서 소스 및 렌디션 개체에 액세스할 수 있습니다. source.path
이(가) 이미 있으며 원본 파일의 로컬 복사본 경로입니다. rendition.path
은(는) 처리된 렌디션을 저장해야 하는 경로입니다. disableSourceDownload 플래그가 설정되지 않은 경우 응용 프로그램에서 정확히 rendition.path
을(를) 사용해야 합니다. 그렇지 않으면 SDK에서 렌디션 파일을 찾거나 식별할 수 없으며, 실패합니다.
예제의 지나친 단순화는 사용자 정의 애플리케이션의 구조를 설명하고 집중하기 위해 수행됩니다. 소스 파일을 렌디션 대상에 복사하기만 하면 됩니다.
렌디션 콜백 매개 변수에 대한 자세한 내용은 SDK API Asset compute를 참조하십시오.