|
Hello, I need to upload a file to my server, and then i need to move this uploaded file to another directory and change the name of it. |
|
The solution I gave you writes in the database the path to the file, but the file is stored on the file system in the specific folder you set. If this is not what you want, can you make an example? If you just store the file on the file system, you wont' be able to retrieve the file in the Web application using the standard units. In any case, to do this you have to model a Script Unit that stores the file where you want. You can refer to the official WIKI ( http://wiki.webratio.com/index.php/Getting_started_with_the_Script_unit). In the Script Unit you have to write down the Java code necessary in order to save the file in a specific position. |
|
You should first decide whether you need to have the file mapped to an entity (and therefore accessible via standard entity-based units) or not. If you don't want to permanently store the file on DB but still would like to map it to an entity, a solution could be creating an ad-hoc entity with Duration set to volatile (session scope)/volatile (application scope). However, keep in mind that this will last until the user session expires or the application is restarted. On the other end, if you don't want to map a BLOB property but just need to upload a file, you can use a Script Unit like suggested by michela.
Groovy scripts and the RTXBLOBData interface are explained in the WebRatio Wiki. http://wiki.webratio.com/index.php/How_to_deal_with_BLOBs. |
|
Hi, you can model in the Data Model an attribute of type BLOB inside an Entity. In the Properties View of the attribute you can set a specific Upload Path. This means that when you upload a file, it will be saved in the folder "upload/images/photogallery". The upload folder is located by default inside the webapps folder of the Web application.
You can change this default and choose a folder outside the webapps one to store files. This can be done configuring the RTXConfig.properties file. This file can be accessed in this way:
You have to change the uploadDirectory writing an absolute path and then the uploadDirectoryIsAbsolute setting it to "true". In this way you can store files in a specific folder on the file system of the server. For further information about the RTXConfig.properties file you can refer to this article on the WebRatio Official WIKI. Finally, to change the name of the uploaded file with a custom one, you can model an Entry Unit having two fields:
Then, you place a Create Unit over the Entity containing the BLOB attribute. On the coupling of the link connecting the Entry Unit with the Create Unit you will find two couplings available for the BLOB attribute, one is the file itself, the other is the name to assign to the file once it's uploaded. Thanks for the response. But i forgot to explain that I`m not uploading it to a database, i want to upload the file to an specific folder with and specific name. thanks
(28 Sep '11, 10:09)
Juanmos
|
