I am using the File Upload Widget and I would like to control the name of the file.
The user file name won't match what I want/need the filename to be in the repository.
Is there a way to change the name of the user selected file before (or after) uploading the file to the repository?
Background:
I'm using Thingworx 9.3.5-b1258
The file they are uploading is tied to a unique entity name from a database.
I want to use the unique name for the file in the repository for retrieval when the database record is selected. The file name the user has most likely will not match the name in the database.
Hi @LynnM ,
You use the Repository entity service called RenameFile to rename the file based on your required by any of unqiue combination. You can also execute this service once the user upload the file through the FileUpload widget. It will help to maintain the file names as unique.
Things["SystemRepository"].RenameFile({
path: p_PathName /* STRING */,
name: p_NewFileName /* STRING */,
overwrite: true /* BOOLEAN {"defaultValue":false} */
});
Thanks & Regards,
Arun C
Rename looks straight-forward and shouldn't be a problem IF the filename selected by the user can be captured.
I bound the ptcsfileupload "FileNames" property to a label so I could capture the name of the uploaded file but as soon as the "Upload" button is clicked, the FileNames property is nulled out.
How can I capture and keep the value of the FileNames property so I know what user filename to rename as what I want it to be?
I added a property UserFilename and two services to my FileRepository.
SaveUserFileName updates the UserFilename property if the filename isn't null
GetUserFileName returns the UserFilename property