Message Boards

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Access uploaded files
Answer
5/26/14 4:24 PM
Hi there,

I created a portlet like this. But I dont know how to access the downloaded files in lifray 6.2?

RE: Access uploaded files
Answer
5/26/14 5:53 PM as a reply to beppo ivel.
If your field definition is like this:
 1....
 2...
 3<field>
 4      <name>myDocument</name>
 5      <title>Doc</title>
 6      <type>
 7            <document></document>
 8      </type>
 9          .....
10
11</field>
Simply use this API:
1PortletFileRepositoryUtil.getPortletFileEntry(myentity.getMyDocument());

Hope it helps..

RE: Access uploaded files
Answer
5/27/14 9:24 AM as a reply to Juan G..
Thx, I tried to edit the autogenerated code, till now I get no working result. Is it possible to define the file download via xml definition file? I would show you my example but the file upload size here in the forum is to low. I build the application on the following xml:
 1<?xml version="1.0" encoding="utf-8"?>
 2<definition xmlns="http://www.xmlportletfactory.org/xml/xmlportletfactory"
 3    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4    xsi:schemaLocation="http://www.xmlportletfactory.org/xml/xmlportletfactory xmlportletfactory.xsd">
 5    <commonData>
 6        <client>Example01</client>
 7        <projectName>egTest</projectName>
 8        <version>1</version>
 9    </commonData>
10    <applications>
11        <!-- egTest Portlet Class and File definition -->
12        <application>
13            <classDef>
14                <name>egTest</name>
15                <title>hallo</title>
16                <restrictBy>
17                    <userId>false</userId>
18                </restrictBy>
19                <mode>
20                    <add>true</add>
21                    <delete>true</delete>
22                    <modify>true</modify>
23                    <browse>true</browse>
24                </mode>
25            </classDef>
26            <fileDef>
27                <name>egTest</name>
28                <fields>
29                    <field>
30                        <name>egTestId</name>
31                        <title>egTest Id</title>
32                        <type>
33                            <long>
34                                <length>5</length>
35                                <signed>false</signed>
36                                <nullable>false</nullable>
37                            </long>
38                        </type>
39                        <showFieldInView>false</showFieldInView>
40                    </field>
41                    <field>
42                        <name>egTestDescription</name>
43                        <title>egTest Description</title>
44                        <type>
45                            <varchar>
46                                <length>100</length>
47                            </varchar>
48                        </type>
49                        <showFieldInView>true</showFieldInView>
50                        <required>true</required>
51                    </field>
52                    <field>
53                        <name>userDocument</name>
54                        <title>Document</title>
55                        <type>
56                            <document></document>
57                        </type>
58                        <showFieldInView>true</showFieldInView>
59                        <required>false</required>
60                    </field>
61                </fields>
62            </fileDef>
63        </application>
64    </applications>
65</definition>

RE: Access uploaded files
Answer
5/27/14 9:42 AM as a reply to beppo ivel.
I guess right now the document URL is available only in the edit form of your entity.

You can get the download code part from the editXXXX.jsp.

RE: Access uploaded files
Answer
5/27/14 10:52 AM as a reply to Juan G..
Thats right, in the editegTest.jsp I can fond:
1<% if (egTest.getUserDocument()!=0){
2    FileEntry userDocument_doc = PortletFileRepositoryUtil.getPortletFileEntry(egTest.getUserDocument());
3    String userDocument_url = PortletFileRepositoryUtil.getPortletFileEntryURL(themeDisplay, userDocument_doc, StringPool.BLANK);
4%>

Do you suggest to bind the description field in the viewegTest.jsp to the url?

If I would have more then one document field in my form and I want to package them in a zip after uploading and provide a download url to this zip, how should I build this.

RE: Access uploaded files
Answer
5/27/14 1:49 PM as a reply to beppo ivel.
I tried to modify the view:

1 <span class="aui-field-element">
2 <% FileEntry userDocument_doc = PortletFileRepositoryUtil.getPortletFileEntry(testB.getUserDocumentA());
3    String userDocument_url = PortletFileRepositoryUtil.getPortletFileEntryURL(themeDisplay, userDocument_doc, StringPool.BLANK);
4  %>
5  <aui:a href="<%= userDocument_url %>" target="_blank"><img alt="" src="<%= userDocument_url %>" width="100"><%= testB.getTestBDescription() %></aui:a>
6</span>

but it does not work. An other thing is, if I define two fields of type document in my definition file like:
 1<field>
 2                        <name>userDocumentA</name>
 3                        <title>Document A</title>
 4                        <type>
 5                            <document></document>
 6                        </type>
 7                        <showFieldInView>true</showFieldInView>
 8                        <required>false</required>
 9                    </field>
10<field>
11                        <name>userDocumentB</name>
12                        <title>Document B</title>
13                        <type>
14                            <document></document>
15                        </type>
16                        <showFieldInView>true</showFieldInView>
17                        <required>false</required>
18                    </field>

I got the failure "Your request failed to complete." by uploading files.

RE: Access uploaded files
Answer
6/3/14 7:10 AM as a reply to beppo ivel.
Can you post the error stacktrace for both use cases?