APS Attachment

cancel
Showing results for 
Search instead for 
Did you mean: 
phoefler
Member II

APS Attachment

Hallo,

I am developing an external webapp (based on Javascript) that is using the alfresco-js-api to communicate with Alfresco Process Services (1.6.0). I want to display an attached document in the browser.

First, the js-api is working fine. I can authorize and connect to Activiti either via credentials or via ticket.

I am trying to open an attachment from a task. I know the js-api provides some function for that purpose.

Basically, I see two possibilities:

  1. I download the content of the file through the js-api and then trying to view it “manually”
  2. I provide the direct url (raw url) to the attachment and by clicking on that link the attachment will be opened.

 

I tried both and both ways have some problems.

When I am going to download the content it’s an asynchronous action. This means, when I am trying to open a new tab after the content has been downloaded, the browser will always recognize this new tab/window as pop up and blocks it. This is not specifically related to the Activiti URL, but to the fact that the download is asynchronous. So, I think it’s not a very good solution. Maybe for desktops it’s easier to make an exception for that URL for the whole landscape, but on mobile end devices it’s quite harder.

 

Then, I tried to provide the raw URL through a hyperlink. Whenever the end user clicks on it the action is synchronous and the browser does not detect this behavior as pop up. Unfortunately, I am not able to pass the credentials to this request. This is NOT done via the js-api.

And that’s basically my question. Is there any possibility to authorize to Activiti through a hyperlink whether via credentials or via ticket?

I tried to find a solution for that by calling the URL with an REST client. I passed the credentials to the request, but it is not working.

Can anybody explain how to properly display an attachment?

Again, the webapp is not based on ADF.

Thanks

2 Replies
dvuika
Alfresco Employee

Re: APS Attachment

Note on the downloading. You can invoke a download action without any popups or user interaction. The "traditional" workaround is to create a hyperlink dynamically and invoke the action, here's one of the examples: alfresco-ng2-components/download-zip.dialog.ts at master · Alfresco/alfresco-ng2-components · GitHub 

We also got several helper functions to invoke the download of the raw data when fetched from the ACS/APS in the ContentService: alfresco-ng2-components/content.service.ts at master · Alfresco/alfresco-ng2-components · GitHub 

You can refer to the code for some snippets or ideas how to do that with just js-api.

phoefler
Member II

Re: APS Attachment

Hallo Denys,

thanks for your reply.

I am not sure if I understand your suggestion completely.

As far as I understood you would recommend generating an dynamic hyperlink to the raw URL of the content.

For example this URL can look like this: https://HOST/activiti-app/app/rest/content/2002/raw

I can generate such a url and show the hyperlink to the user. Then, the problem is, that the request is not authorized.

This is exactly the solution I've described with point 2 in my initial post. Maybe I do not get your suggestion at this point. When calling this URL with a REST client a HTTP401 is returned even when the Basic Auth is set.REST Client calling raw URL

Other requests like tasks/query are working fine this way.