Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.
Nível 1
Nível 2
Faça login na Comunidade
Faça logon para exibir todas as medalhas
Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.
Hi,
I have a image in local drive. I want to upload that image to in my AEM dam. For that I have written following code.
public class ThroughHttpPost { public static void main(String[] args) { // TODO Auto-generated method stub File file = new File("D:\\images\\test.jpg"); byte[] bytesArray = new byte[(int) file.length()]; FileInputStream fis; try { fis = new FileInputStream(file); fis.read(bytesArray); //read file into bytes[] fis.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } DefaultHttpClient httpClient = new DefaultHttpClient();//Client HttpPost postRequest = new HttpPost("http://localhost:4502/content/dam/test");//Post Request to specified URL httpClient.getCredentialsProvider().setCredentials( new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin")); ByteArrayBody bab = new ByteArrayBody(bytesArray, "test.jpg"); MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create(); reqEntity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); reqEntity.addPart("test.jpg", bab); postRequest.setEntity(reqEntity.build()); try { HttpResponse response = httpClient.execute(postRequest); response.getStatusLine(); System.out.println("done"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
I am able to push that image to dam. But the problem is that it is taking the image as nt:file. It doesn't have any metadata as shown in attachment.
Solucionado! Ir para a Solução.
Visualizações
respostas
Total de curtidas
The outside Java app should only post to an AEM servlet.
So you need 2 parts:
1 - outside client app (which you have) that posts files to AEM.
2 - an AEM Sling servlet that uses the AssetManager API
See this article that does this exact use case from a outside Java Swing client:
https://helpx.adobe.com/experience-manager/using/multiple-digital-assets.html
Use of the AssetManager API is the best way when you want to upload files from an outside client.
Visualizações
respostas
Total de curtidas
When coding the Servlet that accepts the file - use the AssetManager API. See this article --
https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html
Hope this helps...
Visualizações
respostas
Total de curtidas
This will help only when my servlet inside OSGI container. But mine is standalone application. I am using it outside the AEM server. In the above link we are getting ResourceResolver from ResourceResolverFactory. In my case it will give null for ResourceResolver.
For your info If I have tried this using curl command
curl -u admin:admin -T D:\images\test.jpg http://localhost:4502/content/dam/test/test.jpg
It is working fine. I am getting metadata. But mine is java application.
Visualizações
respostas
Total de curtidas
The outside Java app should only post to an AEM servlet.
So you need 2 parts:
1 - outside client app (which you have) that posts files to AEM.
2 - an AEM Sling servlet that uses the AssetManager API
See this article that does this exact use case from a outside Java Swing client:
https://helpx.adobe.com/experience-manager/using/multiple-digital-assets.html
Use of the AssetManager API is the best way when you want to upload files from an outside client.
Visualizações
respostas
Total de curtidas
We have a video on our youtube channel that shows this use case: https://www.youtube.com/watch?v=smrFuVLfiBc
Visualizações
respostas
Total de curtidas
Thanks smacdonald. It is working as expected.
Visualizações
respostas
Total de curtidas
Visualizações
Curtida
respostas
Visualizações
Curtida
respostas
Visualizações
Curtida
respostas