I am trying to upload an asset to my local AEMaaCS instance using the Asset Upload Api (specifically with the aem-upload node package). When I make the request I am not getting the URI that the document says I should.
Here is the request that I am using:
const encodedAuth = Buffer.from(`${username}:${password}`).toString('base64');
const uploadFiles = [
{
fileName: 'test.png',
fileSize: 4994,
filePath: './src/resources/test.png'
}
];
const upload = new DirectBinaryUpload();
upload.on('filestart', data => {
console.log('filestart:', data);
});
upload.on('fileprogress', data => {
console.log('fileProgress:', data);
});
upload.on('fileend', data => {
console.log('FileEnd:', data);
});
upload.on('fileerror', data => {
console.log('FileError:', data);
});
const options = new DirectBinaryUploadOptions()
.withUrl('http://localhost:4502'+'/content/dam/test')
.withUploadFiles(uploadFiles);
options.withHeaders({
'content-type': 'image/png',
'authorization': `Basic ${encodedAuth}`
});
const uploadResult = await upload.uploadFiles(options)
.then(result => {
return result;
})
.catch(error => {
console.log('error:', error);
return error;
});
And the Response I recieve:
FileError: { fileName: 'test.png',
fileSize: 4994,
targetFolder: '/content/dam/test',
targetFile: '/content/dam/test/test.png',
sourceFolder: '/home/node/app/src/resources',
sourceFile: '/home/node/app/src/resources/test.png',
errors:
[ { Error: 'completeURI' field invalid in initiateUpload response: {"folderPath":"/content/dam/test","files":[{"fileName":"test.png"}]}
at UploadError.<anonymous> (/home/node/app/node_modules/core-js/internals/wrap-error-constructor-with-cause.js:37:62)
at new Error (/home/node/app/node_modules/core-js/modules/es.error.cause.js:28:43)
at new BlockTransferError (/home/node/app/node_modules/@adobe/httptransfer/es2015/block/blocktransfer-error.js:48:5)
at new UploadError (/home/node/app/node_modules/@adobe/httptransfer/es2015/block/upload-error.js:100:5)
at Function.fromError (/home/node/app/node_modules/@adobe/httptransfer/es2015/block/upload-error.js:76:14)
at TransferController.controller.on.transferEvent (/home/node/app/node_modules/@adobe/httptransfer/es2015/aem/aemupload.js:324:34)
at TransferController.emit (events.js:182:13)
at TransferController.notifyError (/home/node/app/node_modules/@adobe/httptransfer/es2015/controller/transfercontroller.js:208:10)
at /home/node/app/node_modules/@adobe/httptransfer/es2015/functions/aeminitiateupload.js:371:22
at Generator.next (<anonymous>)
code: 'EUNKNOWN',
innerStack:
'Error: \'completeURI\' field invalid in initiateUpload response: {"folderPath":"/content/dam/test","files":[{"fileName":"test.png"}]}\n at /home/node/app/node_modules/core-js/internals/wrap-error-constructor-with-cause.js:37:62\n at Error (/home/node/app/node_modules/core-js/modules/es.error.cause.js:28:43)\n at /home/node/app/node_modules/@adobe/httptransfer/es2015/functions/aeminitiateupload.js:309:17\n at Generator.next (<anonymous>)\n at resume (/home/node/app/node_modules/@adobe/httptransfer/es2015/functions/aeminitiateupload.js:142:362)\n at /home/node/app/node_modules/@adobe/httptransfer/es2015/functions/aeminitiateupload.js:142:540\n at process._tickCallback (internal/process/next_tick.js:68:7)',
uploadError: true } ] }
I also noticed the following in my instance's error logs. I don't understand the "missing field: fileName" error as I am setting it as the documentation specifies in my example above and it is in the response.
Any help would be appreciated!
Solved! Go to Solution.
Views
Replies
Total Likes
According to this source, https://medium.com/adobetech/introduction-to-aem-as-a-cloud-service-asset-upload-http-api-fc560ffd72... the upload api does not work with local instances of AEMaaCS.
According to this source, https://medium.com/adobetech/introduction-to-aem-as-a-cloud-service-asset-upload-http-api-fc560ffd72... the upload api does not work with local instances of AEMaaCS.
Views
Likes
Replies
Views
Like
Replies