1 person found this helpful
Have to do some guessing here, but it appears that your customization is using LiveCycle DataServices Remoting to call your custom component. Remoting automatically converts an output parm with type=com.adobe.idp.Document into a DocumentReference which contains the DocumentManager url with the content-type added as the "type" parameter (content-type vale is Base64 encoded).
When an attachment is added, it may not have the content-type set in the Document so in the workspace-server/documents servlet we have the following code to set it after we fetch the attachment or form document from taskmanager. You will need the same type of code to set the document's content-type before you return the document from your custom component.
String wsFileName = (String)doc.getAttribute("wsfilename");
(Not really sure why we also set the "fileName" attribute but we do, so I thought I would include it.)
Thank you for your reply.
In workbench I created a process to use my custom component.
Input is processId and fileName, output is a document variable.
The output is as follow:
I see the content type is "application/pdf" already.
By the way, could you tell me where is the method setContentTypeFromBasename() from the Document class? (I assume that the doc variable is Document class)
Since the attachment you are displaying has a content type of application/pdf, it will be displayed properly. It depends on how the attachment is loaded whether or not it will have the proper content type.
In your first email, you provided a DocumentManger url that had the type parm specified as "type=YXBwbGljYXRpb24vb2N0ZXQtc3RyZWFt"
I took this value and found an online Base64 decoder and the value becomes "application/octet-stream" (note if you want to try it yourself, remember to add "==" to the end). This mime type is not mapped to any specific program so the browser needs to prompt the user to ask what it is supposed to do with it.
The setContentTypeFromBasename() is a method on the Document class. Use this in your custom java component.
Thank you for your reply.
In my client side code, when i receive the url https://mydomain/DocumentManager/docm1266831910962/53650adc3948bd502cf8c81d4885f eec?type=YXBwbGljYXRpb24vb2N0ZXQtc3RyZWFt, i remove the "?type=YXBwbGljYXRpb24vb2N0ZXQtc3RyZWFt" and navigate to the 1st part of URL, i,e, I navigate to https://mydomain/DocumentManager/docm1266831910962/53650adc3948bd502cf8c81d4885f eec
By the way, I have noticed the difference with the URL in local and client side.
Client side returns me the "?type=YXBwbGljYXRpb24vb2N0ZXQtc3RyZWFt" (application/octet-stream) while local environment returns me the "?type=YXBwbGljYXRpb24vcGRm"(application/pdf)
In Server side, the custom component is used in a short-live process, it retrieves list of attachment base on taskId, then set into the list variable. An attachment will be set into a document output-variable.
In client side, it will call above web service, resultFormat is e4x and parse the content to get the url.
It is the same code and retrieve the same type of attachment pdf but the content type returned are different, what factor do you think that it can affect the content type? is it relate to environment?
In local development we use windows XP as server, in client side, they use IBM AIX as server.
For the method setContentTypeFromBasename(), i cannot find it in the API of com.adobe.idp.Document
In the eclipse i also cannot find it. Please advise.
Thank you and regards,
You are confusing me
But first, the setContentTypeFromBasename() is an ES2 addition to the Document class. Didn't realize this was a pre-ES2 case. Sorry about that.
Next, you say you are removing the ?type=ASDFASDFASDF from the url on the client. This must be there so the DocumentManager servlet can set the proper content-type in the http response. I looked at the code and if it isn't there, no content type is set so it will be browser and os dependent on what it will do,although i would expect most to prompt.
And however your custom component and the short lived process work, that document output variable needs to have the proper content-type set in it (the Document has a setContentType() method in 8.2 but you will have to do the mapping from file extension to mime-type yourself in 8.2). If it does and you don't remove the type parm from the url, then things will work. But if that type parm isn't there or the content-type isn't set in the document output var, the browser will not know which application/plugin to launch and will prompt.
Thank you for your great help.
Yes, this is LCES 8.2.1, sorry for not make it clear at the first post.
During development when I try to remove the part "?type=YXBwbGljYXRpb24vb2N0ZXQtc3RyZWFt" it is still able to display the PDF form in the browser, therefore I thought it is not needed. Now I know that it is needed for DocumentManager, I will add it back and test in client side again.
Thank you very much for your help.
After setting the content-type to "application/pdf" and remain the part "?type=...", client has been able to view the form in the browser.
Thank you again and regards,