Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Assets 6.4 HTTP API - Upload asset

Avatar

Level 1

Hi all,

 

In the AEM Assets documentation it is written that a new asset can be created with the following POST request:

POST /api/assets/myFolder/* -F"name=myAsset.png" -F"file=@myPicture.png"

 

Could you please provide more information on what is expected as a value for file property? I have tried uploading it with a path to the image, but every time I try to create an asset I end up creating a new folder.

 

What is the correct way to upload an asset via HTTP API?

 

All the best!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi There,

 

How are you firing your POST? Using curl? Postman?

 

It is necessary to have a folder pre-existing where you want to upload an image.

 

For example I use following command from curl console and it works:

curl http://localhost:4502/api/assets/my-image123.jpeg -H"Content-Type: image/jpeg" --upload-file "preview_Monitor_template.psd" -v --user admin

 

Try --upload-file to pass binary file.

 

Thanks!

View solution in original post

2 Replies

Avatar

Correct answer by
Level 4

Hi There,

 

How are you firing your POST? Using curl? Postman?

 

It is necessary to have a folder pre-existing where you want to upload an image.

 

For example I use following command from curl console and it works:

curl http://localhost:4502/api/assets/my-image123.jpeg -H"Content-Type: image/jpeg" --upload-file "preview_Monitor_template.psd" -v --user admin

 

Try --upload-file to pass binary file.

 

Thanks!

Avatar

Level 2
How achieve that with HTTP request (for instance by axios)?