-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Hi, i have a problem uploading files to the aem and due to this problem i dont know the "real" problem.
Currently the Module cant parse the response it receives, because it is not a JSON content.
I try to upload several files to different directories by using the file "FileSystemUpload" class several times (once for each target directory)
e.g.
first call with files:
- content/dam/US/pdf/subdir/file_1
second call with file:
- content/dam/US/pdf/subdir/sub_sub_dir/file_2
- content/dam/US/pdf/subdir/sub_sub_dir/file_3
third call with file:
- content/dam/US/pdf/file_4
Expected Behaviour
Upload works fine for each call
Actual Behaviour
During the upload for the "second call" the module is not able to parse the response, because its not a JSON content.
UploadError: Unexpected token '<', "<html>
<he"... is not valid JSON while parsing '<html>
<head>
<title>Content created'
at UploadError.fromError (/builds/n-tier-application/adobe-asset-upload-test/node_modules/@adobe/httptransfer/lib/block/upload-error.js:72:20)
at TransferController.<anonymous> (/builds/n-tier-application/adobe-asset-upload-test/node_modules/@adobe/httptransfer/lib/aem/aemupload.js:53:43)
at TransferController.emit (node:events:514:28)
at TransferController.notifyError (/builds/n-tier-application/adobe-asset-upload-test/node_modules/@adobe/httptransfer/lib/controller/transfercontroller.js:186:14)
at AEMInitiateUpload.execute (/builds/n-tier-application/adobe-asset-upload-test/node_modules/@adobe/httptransfer/lib/functions/aeminitiateupload.js:171:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async executeBatch (/builds/n-tier-application/adobe-asset-upload-test/node_modules/@adobe/httptransfer/lib/generator/mapconcurrent.js:79:22)
at async waitResult (/builds/n-tier-application/adobe-asset-upload-test/node_modules/@adobe/httptransfer/lib/generator/mapconcurrent.js:35:37)
at async MapConcurrent.execute (/builds/n-tier-application/adobe-asset-upload-test/node_modules/@adobe/httptransfer/lib/generator/mapconcurrent.js:[159](https://gitlab.aldidevops.com/n-tier-application/adobe-asset-upload-test/-/jobs/13520219#L159):20)
at async FilterFailedAssets.execute (/builds/n-tier-application/adobe-asset-upload-test/node_modules/@adobe/httptransfer/lib/functions/filterfailedassets.js:30:26) {
code: 'EUNKNOWN',
innerStack: `SyntaxError: Unexpected token '<', "<html>\n` +
`<he"... is not valid JSON while parsing '<html>\n` +
'<head>\n' +
" <title>Content created'\n" +
' at JSON.parse (<anonymous>)\n' +
' at parseJson (/builds/n-tier-application/adobe-asset-upload-test/node_modules/json-parse-better-errors/index.js:7:17)\n' +
' at /builds/n-tier-application/adobe-asset-upload-test/node_modules/node-fetch-npm/src/body.js:96:50\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
' at async Immediate.invoke (/builds/n-tier-application/adobe-asset-upload-test/node_modules/@adobe/httptransfer/lib/retry.js:[171](https://gitlab.aldidevops.com/n-tier-application/adobe-asset-upload-test/-/jobs/13520219#L171):32)',
uploadError: true
}
Reproduce Scenario (including but not limited to)
This is my current used code
const options = new FileSystemUploadOptions()
// uploadUrl will be dynamically created - depending on the folder structure
// (e.g. https://author-xxxx.adobeaemcloud.com/content/dam/US/pdf/subdir/sub_sub_dir)
.withUrl(uploadUrl)
.withHttpOptions(
{
headers: {
Authorization: 'Bearer ' + accessToken
}
}
);
const fileUpload = new FileSystemUpload();
// filesToUpload == list of local file paths
await fileUpload.upload(options, filesToUpload
).then(result => {
const {detailedResult = []} = result;
detailedResult.forEach((fileResult) => {
const {result = {}} = fileResult;
const {errors = []} = result;
// ATM we dont need the result object
// console.log(`Result: ${fileResult}`)
if (errors.length === 0) {
console.info(`>>>>> Successfully uploaded files <<<<<`);
} else {
process.exitCode = 1;
console.error(">>>>> Upload failed <<<<<");
errors.forEach((err) => {
console.error(err);
});
}
});
}).catch(err => {
console.error("Unexpected Error during Upload - ", err.message);
console.error(err);
process.exitCode = 1;
});
Steps to Reproduce
Platform and Version
Sample Code that illustrates the problem
Logs taken while reproducing problem
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels