Questions Tagged With fileuploadhttps://answers.axonivy.com/tags/fileupload/?type=rssquestions tagged <span class="tag">fileupload</span>enThu, 18 Apr 2019 04:05:19 -0400How to upload a File to a REST apihttps://answers.axonivy.com/questions/3777/how-to-upload-a-file-to-a-rest-api<p>I am building a document management service with a RESTful API. </p> <pre><code>@Path("fileUpload") public class FileUploadService { @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.MULTIPART_FORM_DATA) public Response uploadFile(@FormDataParam("file") InputStream fileStream, @FormDataParam("file") FormDataContentDisposition fileDetail) throws IOException { .... } } </code></pre> <p>It seems to work as expected if I use a third party client such as Postman. However, when using the REST activity of ivy I am unable to call this service. I always get errors stating the the header <code>X-Requested-By</code> is missing. Whats the issue? How can I send files using a REST Client Call activity?</p>SupportIvyTeamThu, 18 Apr 2019 04:05:19 -0400https://answers.axonivy.com/questions/3777/how-to-upload-a-file-to-a-rest-apifileuploadrestfileHow can i save bytearrays via the entityclass in a database?https://answers.axonivy.com/questions/3478/how-can-i-save-bytearrays-via-the-entityclass-in-a-database<p>Hello,</p> <p>I am trying to set up an entityclass with a postgres server. I need this database to store some images i upload with the primefaces <code>&amp;lt; p:fileUpload/&gt;</code> tag. With this tag the images are uploaded as a <code>UploadedFile</code>, now I can access the contents via <code>getContents()</code> and I will get the image as a Bytearray (byte[] in Java) . </p> <p>Now I need to know how can i save this Byte Array via the entityclasses in my postgres database. Postgres allows the datatype <code>bytea</code> for a column for this datatype, but if I add Bytearray as a type for the column in the entityclass AxonIvy throws this error: <code>The field type 'Binary' does not support persistence</code>. </p> <p>So my question is:<br> Is there any possibility i can save bytearray or blobs on my postgres server via the entity class?<br> What are all the classes which <strong>support</strong> <em>persistence</em>?</p> <p>Thanks</p>markusinhoThu, 11 Oct 2018 11:00:01 -0400https://answers.axonivy.com/questions/3478/how-can-i-save-bytearrays-via-the-entityclass-in-a-databasefileuploadpersistencedatabaseHow to read file from a subfolder in files/application?https://answers.axonivy.com/questions/2529/how-to-read-file-from-a-subfolder-in-files-application<p>Hello,</p> <p>we created a subfolder in files/application and uploaded a file in this subfolder. Now I would like to read this file to send it as an Email-attachment.</p> <pre><code>File f = new File("subfolder\\testfile.pdf",false); java.io.File Anhang =new java.io.File(f.getName()); in.anhang=Anhang; </code></pre> <p>But ivy doesn't find the File. When we upload the file directly in files/application it works.</p> <p>Thank you.</p>hayitFri, 24 Mar 2017 13:48:34 -0400https://answers.axonivy.com/questions/2529/how-to-read-file-from-a-subfolder-in-files-applicationfileuploademailfileHow to post a file to a start ivp "Requests Start"https://answers.axonivy.com/questions/1559/how-to-post-a-file-to-a-start-ivp-requests-start<p>Hello, I have an example JSP page: </p><pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt;File Upload Form&lt;/title&gt; &lt;/head&gt; &lt;body&gt; This form allows you to upload a file to the server.&lt;br&gt; &lt;form action="<a href='http://localhost:8081/ivy/pro/designer/HREventManager_ivy/150FEF18A5DB6168/start3.ivp"'>http://localhost:8081/ivy/pro/designer/HREventManager_ivy/150FEF18A5DB6168/start3.ivp"</a> method="post" enctype="multipart/form-data"&gt;&lt;br&gt; Type (or select) Filename: &lt;input type="file" name="uploadFile"&gt; &lt;input type="submit" value="Upload File"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre><p></p> <p>In the start3.ivp page, I have the java code to check the file stream: </p><pre><code>import java.io.StringWriter; import org.apache.commons.io.IOUtils; import javax.servlet.http.Part; import ch.ivyteam.ivy.htmldialog.request.impl.HttpProcessRequest; import javax.servlet.http.HttpServletRequest; import java.util.Iterator; Iterator parameters = ivy.request.getParameterNames(); while(parameters.hasNext()){ String name = parameters.next() as String; ivy.log.error(name); ivy.log.error(ivy.request.getParameter(name).getClass()); ivy.log.error(ivy.request.getParameter(name)); } <br> HttpProcessRequest r = ivy.request as HttpProcessRequest; ivy.log.info("r="+r); HttpServletRequest o =r.getHttpServletRequest(); ivy.log.info("o="+o); ivy.log.info("content length="+o.getContentLength());<p></p> <p>ivy.log.info("part="+o.getParts());</p> </code><p><code>ivy.log.info(o.getMethod()); </code></p></pre><p></p> <p>When run the form,I see nothing in the log about o.getParts. Here is the full output: </p><pre><code> uploadFile class java.lang.String 5z.doc r=HTTP POST Start Processes/BadgeRequestProcess.mod/start3.ivp(553.553.0.0) o=org.apache.catalina.connector.RequestFacade@4c384c5a part=[] org.apache.catalina.connector.CoyoteInputStream@77da5b0a POST </code></pre><p></p> <p>I use: Xpert.ivy Designer Version: 5.0.11 (Rothorn) Revision: 45786 Build date: May 14, 2014</p>NhutNguyenMon, 16 Nov 2015 05:07:28 -0500https://answers.axonivy.com/questions/1559/how-to-post-a-file-to-a-start-ivp-requests-startfileuploadFile management in 5.1.2 jSFhttps://answers.axonivy.com/questions/1120/file-management-in-5-1-2-jsf<p>Hello,</p> <p>i am actually migration a 4.3 RIA application (which i didn't wrote) to a 5.1.2 JSF application.</p> <p>In the old application we were using the workflowUI and something called DocumentWrapper to take care of the Files linked to a case. Does something similar exist in 5.1.2 JSF ? I've found in the addOns the whole ch.ivyteam.ivy.addons.filemanager package. It is used for RIA but could we reuse something ? Or do we have to develop the whole thing ?</p> <p>Is storing files in a CMS an option ?</p>dbalasseThu, 15 Jan 2015 17:15:29 -0500https://answers.axonivy.com/questions/1120/file-management-in-5-1-2-jsfjsffileuploadfileXpertIvy / SQL : How can i write a file in a sql db?https://answers.axonivy.com/questions/1001/xpertivy-sql-how-can-i-write-a-file-in-a-sql-db<p>Hello guys i have the the xpertivy v5....following process: User have to upload a pdf file. #1 Step The pdf file have to save into a postsql db (bytea field). #2 Step The user have to open the file from db What have i done? I created a java method. I can save and read a pdf from the postsqldb but it wont work in the xpert ivy process. How can i fetch a file over the fileinputstream with the databasestep and write it to the db? How can i read the file over the db step? </p> <p>Thank you so much for your help</p>MaxIvyMon, 13 Oct 2014 15:37:37 -0400https://answers.axonivy.com/questions/1001/xpertivy-sql-how-can-i-write-a-file-in-a-sql-dbfileuploadfileDynamic amount of fileuploads: file not uploadinghttps://answers.axonivy.com/questions/273/dynamic-amount-of-fileuploads-file-not-uploading<p>I'd like to give the user the ability to choose the amount of attachments he'd like to provide. To do this I created a datatable with buttons to add and remove attachment-lines:</p> <pre><code>&lt;p:dataTable id="attachments" var="attachment" value="#{data.attachments}"&gt; &lt;p:column headerText="#{ivy.cms.co('/labels/vendor')}"&gt;&lt;p:inputText value="#{attachment.vendor}" /&gt;&lt;/p:column&gt; &lt;p:column headerText="#{ivy.cms.co('/labels/description')}"&gt;&lt;p:inputText value="#{attachment.description}" /&gt;&lt;/p:column&gt; &lt;p:column headerText="#{ivy.cms.co('/labels/amount')}"&gt;&lt;p:inputText value="#{attachment.amount}" /&gt;&lt;/p:column&gt; &lt;p:column headerText="#{ivy.cms.co('/labels/attachment')}"&gt;&lt;p:fileUpload value="#{attachment.file}" mode="simple" /&gt;&lt;/p:column&gt; &lt;p:column headerText=""&gt;&lt;p:commandButton value="delete-row" update="attachments" action="#{logic.deleteAttachment(attachment)}" /&gt;&lt;p:commandButton value="add-row" update="attachments" action="#{logic.addAttachment()}" /&gt; &lt;/p:column&gt; &lt;/p:dataTable&gt; </code></pre> <p>The only problem is, that it seems to not upload the specified file. The submitted form is beeing processed by this script, the output of <strong>in.test</strong> beeing <strong>false</strong>:</p> <pre><code>for(Integer i = 0; i &lt; in.attachments.size(); i++) { in.test = in.attachments.get(i).file.exists().toString(); } </code></pre> <p>The Simple-Fileupload-Demo works, so I guess it can't be a problem with my installation / computer. I just cleared all of the attachments and uploaded only one. So while this is a foor loop, it just iterates through 1 time. Data is stored in my own Data Class <strong>Attachment</strong>, containing 4 attributes (Vendor, Description, Amount and File).</p>ahatiusTue, 21 Jan 2014 20:34:00 -0500https://answers.axonivy.com/questions/273/dynamic-amount-of-fileuploads-file-not-uploadingjsffileupload