uploadButton's Documentation/SDK Error

It seems like some of the expected capabilities are not available https://www.wix.com/corvid/reference/$w.UploadButton.html#value → supposedly you can ‘set’ uploadButtons’ values.

Syntax
get value(): Array
set value(value: Array): void

Maybe I’m just having bad luck with it?


let uploadButtonString = "#uploadButton1"

// Declare/initialize an array of Files, identical to that of the uploadButton
let tempArray = $w(uploadButtonString).value 

// Change the name of the first File in the array
tempArray[0].name = "TestOverwrite" 

// Set the value of the uploadButton to the new name for the firs File
$w(uploadButtonString).value = tempArray

The above code will give this error: “Wix code SDK error: Cannot set property value of UploadButton which has only a getter”
Clearly, this doesn’t add up, based on the Syntax shown above.

Anyone have any idea what’s going on here? I want to change the name of the file being upload via code… For example if a user uploads 53219380j01e1wu1oij10ud.jpg I want to change that to “FirstName_LastName.jpg”

You can not set the file name that gets saved when users use the upload button as it automatically gets converted to a new name when it is uploaded onto Wix Servers, hence why you get the long winded file name instead of the original file name that the users upload.
https://www.wix.com/corvid/reference/$w.UploadButton.html#value

Hence why you have the void after the set value,
Syntax
get value(): Array
set value(value: Array): void

If you go to the Array link then you will see that you can only get the pending files for uploading.
https://www.wix.com/corvid/reference/$w.UploadButton.html#File

It is the same if you use MediaManager through the backend to upload any files etc.
https://www.wix.com/corvid/reference/wix-media-backend.mediaManager.html

You can vote for the request here.
https://support.wix.com/en/article/request-customizing-document-file-names

I think my point about file names may have been misinterpreted; file name conversion into a long-winded file name is not the issue. Perhaps you interpret I mean the “src” of the actual file.

If I use the upload button, and upload a file named “ABC.jpg”, then that file will appear in the “Visitor Upload” section identical as “ABC.jpg”.
My goal is to make it so when a user uploads “ABC.jpg”, that identical image will appear in the “Visitor Upload” section as “FirstName.jpg”
That is what uploadButton.value[0].name refers to.
Basically, before it even goes into the Wix servers, we should be able to modify the file name. Wix creates a reference to one with their long-winded string, and then we get a file in the “Visitor Upload” section with the modified name.

I don’t understand your comment about “why you have the void after the set value”
void is the return type, the same way in the getter, the return type is Array
According to the documentation, the setter should be supported:

let arrayOfFiles = $w("#ub1").value; // getter; arrayOfFiles is assigned type of Array<File>

// setter possible implementation 1
$w("ub1").value = arrayOfFiles;

// setter possible implementation 2
$w("ub1").value(arrayOfFiles);

The void return type is common for setter functions.
One of the two implementations above should be supported, since the documentation indicates setters are possible.

If you’re limited to getting the pending documents for upload, then that’s fine, because really all you’re doing is modifying a string for the filename. Nothing about the actual image itself is modified, just what we’re calling it.

Voted for the update anyways, but I think my concern is different.