cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

File Upload Widget File Name(s)

LynnM
6-Contributor

File Upload Widget File Name(s)

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.

3 REPLIES 3
Arun_C
16-Pearl
(To:LynnM)

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

 

LynnM
6-Contributor
(To: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?

LynnM
6-Contributor
(To:LynnM)

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

 

Top Tags