cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco explorer authentication while down loading a file

chanduxyz
Champ on-the-rise
Champ on-the-rise
Hi All,
           I am working on Alfresco share.In that I have a requirement to download a file.When I download a file in share for the 1st time Alfresco Explorer is asking for admin authentication.Next time when I download it is not asking for any authentication.How can I resolve this issue(i.e 1st time also Alfresco Explorer should not ask for authentication when I download the file ). Could you please suggest me the way how to resolve it.Thanks a lot in advance Smiley Happy
18 REPLIES 18

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
I assume you are directly calling going through the web client rather than calling the download webscript…

You should use the following one for the download:
http://localhost:8080/alfresco/service/api/node/content/{store_type}/{store_id}/{id}

So it should look like:

http://localhost:8080/alfresco/service/api/node/content/workspace/SpacesStore/258819c4-337f-44ab-b53...<Your_ticket_value>

chanduxyz
Champ on-the-rise
Champ on-the-rise
Thanks very much Adei

Iam getting the download url from the webscript like this "alfresco/d/a/workspace/SpacesStore/9e4a359f-3efc-4f0b-b6c2-bb78b98504ed/selectone.ftl".
For this I am appending the ticket as follows
http://127.0.0.1:8080/alfresco/d/a/workspace/SpacesStore/9e4a359f-3efc-4f0b-b6c2-bb78b98504ed/select....

But still it is asking for Alfresco Explorer Authentication.

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
Could you use the one I posted in the previous reply instead? The one you are using goes directly to the web client (that's why is asking you for credentials).

chanduxyz
Champ on-the-rise
Champ on-the-rise
Thanks a lot Adei,

I hope I am almost there.I have used "http://localhost:8080/alfresco/service/ … lf_ticket=<Your_ticket_value>".i.e

"http://127.0.0.1:8080/alfresco/service/api/node/content/workspace/SpacesStore/9e4a359f-3efc-4f0b-b6c... I enter this url,the file(selectone.ftl) which I want to download is opened.it is not getting downloaded.

Could you please guide me is there any way to download the file(selectone.ftl).

chanduxyz
Champ on-the-rise
Champ on-the-rise
Hi ,
                Thank you very much Adei,It is working for files which are not compatible with the browser(i.e .doc,.docx…etc).But when I download .xml,.html,.ftl….etc which are browser compatible are opening in the same page those are not getting downloaded.

Anyway Thanks a lot Adei

shazada
Star Contributor
Star Contributor
Check the wiki http://wiki.alfresco.com/wiki/URL_Addressability

if you use
http://127.0.0.1:8080/alfresco/d/a/workspace/SpacesStore/9e4a359f-3efc-4f0b-b6c2-bb78b98504ed/myfile...

then it's attaching the file in your browser and not trying to open it  :wink: . Be aware use ticket as param instead of alf_ticket!

saina
Champ in-the-making
Champ in-the-making
Hi All,
Am currently working on Alfresco 4.0 share. I have few custom content types created in share.
I Created a folder ,applied versionable rule to it and created few custom content types and Out of the box content types(i.e HTML,Plain Text) inside that folder.I edited a content and saved it.,Since I applied versionable rule there, I can see the previous versions of it..And I want to download the previous version of a content.

Now I want to download these files,am able to download out of box content types but unable to download custom content types.Am getting some Webscript error. The download functionality is out of box one,I don't have any other java/Webscript written for this.


In my share-config-custom.xml these are the content types added.I added node and model types for these.

<create-content>
<content id="plain-text" mimetype="text/plain" label="HelpText" itemid="sk:HelpText" icon="text"/>
<content id="plain-text" mimetype="text/plain" label="ContextualText" itemid="sk:ContextualText" icon="text"/>
</create-content>

Am able to create custom content types properly. But unable to download them.Am getting the following error.

<———- ———————————— error starts here————————————————————>
The Web Script /alfresco/s/api/node/content/versionStore/version2Store/8b995bf4-e54e-419e-a0c7-de4a8897c580/Test1234 has responded with a status of 404 - Not Found.

404 Description: Requested resource is not available.

Message: 11060016 Unable to locate content for node ref versionStore://version2Store/8b995bf4-e … 4a8897c580 (property: {http://www.alfresco.org/model/content/1.0}content)

Exception: org.springframework.extensions.webscripts.WebScriptException - 11060016 Unable to locate content for node ref versionStore://version2Store/8b995bf4-e … 4a8897c580 (property: {http://www.alfresco.org/model/content/1.0}content)

org.alfresco.repo.web.scripts.content.StreamContent.streamContent(StreamContent.java:380)
org.alfresco.repo.web.scripts.content.StreamContent.streamContent(StreamContent.java:315)
org.alfresco.repo.web.scripts.content.ContentGet.execute(ContentGet.java:167)
org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:407)
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:388)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:476)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:514)
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:330)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
java.lang.Thread.run(Thread.java:662)

Server: Enterprise v4.0.2 (.9 38) schema 5,033
Time: Dec 6, 2012 10:49:54 AM

Diagnostics: Inspect Web Script (org/alfresco/cmis/content.get)

<———————————————— error ends here——————————————————–>
<=======================================================================================>


At the end of the error I can see a link to : " Diagnostics: Inspect Web Script (org/alfresco/cmis/content.get)"
when I click on that link I can see the below thing,

Web Script: org/alfresco/cmis/content.get
Generated from /alfresco/s/script/org/alfresco/cmis/content.get on Dec 6, 2012 10:53:30 AM


Script Properties
Id: org/alfresco/cmis/content.get
Short Name: Get Content (getContent)
Description: Gets the content stream for the specified document, or gets a rendition stream for a specified rendition of a document.
Authentication: guest
Transaction: required
Method: GET
URL Template: /cmis/i/{id}/content{property}?a={attach?}&streamId={streamId?}
URL Template: /cmis/s/{store}/i/{id}/content{property}?a={attach?}&streamId={streamId?}
URL Template: /cmis/p{path}/content{property}?a={attach?}&streamId={streamId?}
URL Template: /cmis/s/{store}/p{path}/content{property}?a={attach?}&streamId={streamId?}
URL Template: /api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}&streamId={streamId?}
URL Template: /api/path/content{property}/{store_type}/{store_id}/{nodepath}?a={attach?}&streamId={streamId?}
URL Template: /api/avmpath/content{property}/{store_id}/{avmpath}?a={attach?}&streamId={streamId?}
URL Template: /api/node/{store_type}/{store_id}/{id}/content{property}?a={attach?}&streamId={streamId?}
URL Template: /api/path/{store_type}/{store_id}/{nodepath}/content{property}?a={attach?}&streamId={streamId?}
Format Style: argument
Default Format: [undefined]
Negotiated Formats: [undefined]
Implementation: class org.alfresco.repo.web.scripts.content.ContentGet
Extensions: [undefined]

Store: workspace://SpacesStore/app:company_hom … webscripts


[No implementation files]

Store: workspace://SpacesStore/app:company_hom … webscripts


[No implementation files]

Store: classpath:alfresco/extension/templates/webscripts


[No implementation files]

Store: classpath:alfresco/templates/webscripts



File: org/alfresco/cmis/content.get.desc.xml
<webscript>
<shortname>Get Content (getContent)</shortname>
<description>
<![CDATA[
Gets the content stream for the specified document, or gets a rendition stream for a specified rendition of a document.
]]>
</description>

<!– by object id –>
<url>/cmis/i/{id}/content{property}?a={attach?}&amp;streamId={streamId?}</url>
<url>/cmis/s/{store}/i/{id}/content{property}?a={attach?}&amp;streamId={streamId?}</url>
<!– by path –>
<url>/cmis/p{path}/content{property}?a={attach?}&amp;streamId={streamId?}</url>
<url>/cmis/s/{store}/p{path}/content{property}?a={attach?}&amp;streamId={streamId?}</url>

<!– alfresco style –>
<url>/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}&amp;streamId={streamId?}</url>
<url>/api/path/content{property}/{store_type}/{store_id}/{nodepath}?a={attach?}&amp;streamId={streamId?}</url>
<url>/api/avmpath/content{property}/{store_id}/{avmpath}?a={attach?}&amp;streamId={streamId?}</url>
<url>/api/node/{store_type}/{store_id}/{id}/content{property}?a={attach?}&amp;streamId={streamId?}</url>
<url>/api/path/{store_type}/{store_id}/{nodepath}/content{property}?a={attach?}&amp;streamId={streamId?}</url>

<args>
<arg>
<shortname>store</shortname>
<description>the store name</description>
</arg>
<arg>
<shortname>id</shortname>
<description>the node id of the object</description>
</arg>
<arg>
<shortname>path</shortname>
<description>the path of the object (relative to CMIS root, typically "Company Home")</description>
</arg>
<arg>
<shortname>nodepath</shortname>
<description>the path of the object (relative to root of Alfresco store)</description>
</arg>
<arg>
<shortname>property</shortname>
<description>the name of the content property to retrieve content from</description>
<default>cm:content</default>
</arg>
<arg>
<shortname>attach</shortname>
<description>if true, force download of content as attachment</description>
<default>false</default>
</arg>
<arg>
<shortname>streamId</shortname>
<description>if provided, download the rendition of the content as identified by the stream id</description>
</arg>
</args>

<format default="">argument</format>

<authentication>guest</authentication>
<transaction allow="readonly"/>
<family>CMIS</family>
<lifecycle>deprecated</lifecycle>
</webscript>

Store: classpath:alfresco/enterprise/webscripts


[No implementation files]

Store: classpath:webscripts


[No implementation files]
============================================================================================


One more thing what I observed is, when I am taking previous versions noderef and running that in nodebrowser I am finding cm:content property as null for alfresco model(i.e {http://www.alfresco.org/model/content/1.0}content = null), but for my custom model(i.e sk:content) am seeing content in node browser.when I revert the previous version to my current, its replacing my current version and am able to see the content there..!!!!!

Can someone help me to sort it out…???? It will be a great help..! Thank you,

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
Hi,

you can append another HTTP query parameter to that webscript that forces the download of the file (a=true or a=false). This parameter defines whether you want the file to be attached or not.

Try with it and let me know.

Regards,
Adei

saina
Champ in-the-making
Champ in-the-making
Hi Adei,
Thanks for the reply,
Am very new to alfresco, can you tell/show how to add it in content.get.desc.xml..?

Is it what you were telling..?
<arg>
<shortname>attach</shortname>
<description>if true, force download of contentas attachment</description>
<default>true</default>
</arg>

I added this, value as true, but still getting the same error.

And how to add onemore option in the <arg> tag, like in below property ..,
<arg>
<shortname>property</shortname>
<description>the name of the content property to retrieve content from</description>
<default>cm:content</default>
</arg>

Default value is cm:content which is alfresco out of box, I have my custom content model as sk:content., should I add it there as ,<value>sk:content</value>? If yes is this the <value> tag used for it..?

can you Please help to fix it..?
Thanks  ,

Regards,
Saina