


Hello Community,
It has been a while that I posted something here.
A lot of people want to leverage form with DAM assets. Simple example, you have an adaptive form and you want user to upload the image but instead of saving it in some other system you want to leverage DAM assets.
Two main things for such use case:
Sample:
Create a simple html widget for file upload.
<p>Image</p>
<p><input id="default_file" type="file" name="logo"> <button id="clear">clear</button></p>
Create JS to handle file upload and ingest the payload to DAM API.
$('#default_file').change(function(){
//on change event
formdata = new FormData();
if($(this).prop('files').length > 0)
{
file =$(this).prop('files')[0];
formdata.append("file", file);
formdata.append("name", "yourLogoName.jpeg");
}
jQuery.ajax({
url: "http://localhost:4502/api/assets/test/*",
type: "POST",
data: formdata,
processData: false,
contentType: false,
success: function (result) {
alert("all is well");
},error: function(){alert("some err occurred");}
});
});
Thanks,
Mayank Gandhi
Topics help categorize Community content and increase your ability to discover relevant content.
@Mayank_Gandhi Thank you for sharing this with AEM community. And Good to see you back. Encourage your peers to also contribute to the AEM Community.