Expand my Community achievements bar.

SOLVED

AEM Cloud Service - aem-upload feature - external Java application

Avatar

Level 1

I am trying to upload assets to AEM Cloud Service using the Asset Upload feature since the Assets HTTP API for creating assets is deprecated. The documentation I am using is here: https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/assets/admin/dev...

 

I am getting a successful response for the first step, Initiate Upload and I am using an access token for authentication since this is originating from an external application, per the documentation.

 

But I am running into an issue with the second step, Upload binary. This second step fails with and without authentication. This request throws a 403 FORBIDDEN response stating: "Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature." The documentation does not call out any authentication and even including an access token in the Upload binary request causes it to fail as well with a 400 BAD_REQUEST with the error: "Authentication information is not given in the correct format. Check the value of Authorization header.". I am using a Local Development access token at the moment.

 

Here is a code snippet of the Upload Binary step currently.

 

byte[] fileBytes = IOUtils.toByteArray(file.getInputStream());
HttpEntity<byte[]> request = new HttpEntity<>(fileBytes);
String uploadUri = currentFile.getAsJsonArray("uploadURIs").get(0).getAsString();
ResponseEntity<String> responseEntity = this.restTemplate.exchange(uploadUri, HttpMethod.PUT, request, String.class);

 

Some questions:

  • Is there a feature that needs to be enabled on the target AEM Cloud Service author instance to allow binary uploads? If so, how and where?
  • Can upload/creating assets even be done successfully from an external Java application to AEM Cloud Service? 
  • Is there something that is needed to be included in the Upload binary request from the response of the first step Initiate Upload?

 

1 Accepted Solution

Avatar

Correct answer by
Level 1

This issue has been resolved. The second step, Upload Binary, requires the asset's mimeType to be included in the request as part of the Accept header. Doing so resolved the authentication issue.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 1

This issue has been resolved. The second step, Upload Binary, requires the asset's mimeType to be included in the request as part of the Accept header. Doing so resolved the authentication issue.