adobe / aem-upload

Makes uploading to AEM easier, and can be used as a command line executable or required as a Node.js module.
Apache License 2.0
62 stars 15 forks source link

.initiateUpload.json missing FileName #120

Closed johncvieira closed 8 months ago

johncvieira commented 8 months ago

Expected Behaviour

File to upload

Actual Behaviour

File errors

Environment

AEM Cloud AEM Release: 2023.12.14697.20231215T125030Z

Sample Code that illustrates the problem

const files = [ { fileName: req.file.originalname, fileSize: size, filePath: targetPath } ] let options = new DirectBinary.DirectBinaryUploadOptions() .withUrl(targetAEMUrl) .withUploadFiles(files) .withHttpOptions({ headers: { 'Content-Type': 'application/json', 'Authorization' : Bearer ${accessToken} } }); const upload = new DirectBinary.DirectBinaryUpload(); upload.uploadFiles(options) .then(result => { console.log('result'. result); }) .catch(err => { console.log('err'. err); });

Logs taken while reproducing problem

15.02.2024 17:43:11.413 [cm-p33718-e121022-aem-author-5cc4bf6c74-9fmtv] ERROR [65.110.174.162 [1708018991404] POST /content/dam/folder.initiateUpload.json HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught Throwable java.lang.IllegalArgumentException: Missing field: fileName at com.adobe.cq.assetcompute.impl.servlet.ServletHelper.getStringParameters(ServletHelper.java:78) [com.adobe.cq.dam.cq-dam-processor-nui:1.1.800] at com.adobe.cq.assetcompute.impl.servlet.InitiateUploadAssetServlet.doPost(InitiateUploadAssetServlet.java:152) [com.adobe.cq.dam.cq-dam-processor-nui:1.1.800] at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:146) [org.apache.sling.api:2.27.2] at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:342) [org.apache.sling.api:2.27.2] at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:374) [org.apache.sling.api:2.27.2] at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:545) [org.apache.sling.engine:2.15.10]

johncvieira commented 8 months ago

'Content-Type': 'application/json', I think was causing issues.

The actual error now is unauthorized "Cannot serve request to /content/dam/folder.initiateUpload.json on this server"