Automatic file upload

31 Jan '14, 10:18 AM
Forum Forum Starter - Level 2

In a service task I read a CSV file and for each row I create a record in the database. No problem for normal fields (integer, string, text), but how can I upload a file, starting from a path / file name  in the CSV field?


Luciano Sulis

x 2
Answer Answer at this question and get points!
Forum Starter - Level 2

Partly through the aid of Help Desk WebRatio, partly after several attempts, here is the solution: insert the following script before the Create. I hope this can be useful.

#input String filePath

import com.webratio.rtx.RTXBLOBData
import com.webratio.rtx.blob.BLOBData
import com.webratio.rtx.blob.ExternalBLOBData
import com.webratio.rtx.blob.ByteArrayBLOBData
import org.apache.commons.lang.StringUtils

def path = StringUtils.substringBeforeLast(filePath, "\\")
def fileName = StringUtils.substringAfterLast(filePath, "\\")
def ext = StringUtils.substringAfterLast(filePath, ".")
File inputFile = new File(path, fileName);
RTXBLOBData blobFile = new ExternalBLOBData(fileName, inputFile, rtx);
return blobFile

x 5
Answer at this question and get points!

Related questions

add html Add logging capability to a Groovy script (unit) Add select all to Checkable List Ajax and FCK Editor (WebRatio 5.x) AJAX events problem to external JavaScript Ajax onchange and jQuery 2.x (with migrate plugin) incompatible Ajax on change selection field and modify units Autocomplete template Automatic date in form BPMN: URL field ckeditor - change directory for the browser Clean a form Como crear cambio de contraseƱa Como tener dos botones juntos en un formulario independientes de una accion? Como usar la funciĆ³n autocomplete en un field Compare with the current time Content module page variable won't assign. Convert selector component result to single value coupled mandatory fields Criptare dati sensibili nel database Cryptic error when submitting a form Data flow from a page which is not visible anymore Disabilitare campi durante evento AJAX Drop down menu question Dudas sobre modelado(Data Flow,Forms y Operation Create) Dynamic attribute/field names. Possible? Dynamic instantiation of fields on a page for any Class type Empty record mistakenly saved entry form logic. Entry Unit - Default field timestamp Entry Unity, Field Date Type Error Execute truncate sql query Field as link soruce file analysis then update MySQL database Form element Form template Get size of Multi Form with Pictures Object Array Getting the absolute path of a RTXBLOBData Groovy and Database Groovy script numer after an error Hide form until a flow is triggered Hiding form components based on page conditions Hierarchy component How can I add a credit card payment gateway or integrate paypal in my web app logic? How can i add html into a page? how can i open a pdf file using download dialog How I can receive the primary key value after adding into database from OK Port. How to calculate dates between start and end point? How to redirect to the correct site view after a successful login attempt How to Retreive data from Multi Selection Field Array Importing JAR Libraries into Script Unit Importing jar library input mask JAR importing Merge the result of 2 (or more) flows [MOBILE] Script doesn't work! Modify generated code / inject own HTML, Javascript code into existing generted code. Multi Entry Unit: How to forward only checked rows? Multi-Image Upload Multiple forms on one page. HTML5 input attributes. Possible? (2 questions) multi selections field problem Multi Selects didn't work in update page Prelevare la chiave del record da una Selection Field in una Multiple Form Problem saving multi selection from input Progress bar when uploading big file(s) in a form? Pulire URL Redirecting users to another site view Resize fields script component Script eseguito alla User Login Script Unit e Mysql ScritpUnit and JSON data Search by Selector component does not work selection fields on cascade Select multiple files for upload Setting Upload directory Showing items that have a relation with an entity Shuffling Script Slot in Selection Field Standard confirm dialog replacement Unable to execute the script java.lang.NullPointerException Update fields based on selection of other fields Updating attributes of an entity upload file and the move it to other location upload file html Uppercase Uso de la componente chart de webRatio Validacion validation fields Value Length (Min) fails to validate when field is empty? WebRatio 6.1.2: Groovy Version / Versione Groovy WebRation - Create Navigation diagram What are the new features of WebRatio 6.1? which of these three models is closer to webratio/ifml way of creating web applications