cancel
Showing results for 
Search instead for 
Did you mean: 

Rename Filename

0 Kudos

Hi,

I ask a question about uploadcollection.When ı upload a file,if filename length is greater than maximumFilenameLength,filenameLengthExceed function execute.But ı want to change filename and execute change function,if filename length is greater than maximumFilenameLength.How can ı do this function.

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

former_member560141
Participant
0 Kudos

I am doing the same thing.

fileExt = oFile.name.split(".");
if (fileExt[0].length > 45) { fileName = fileExt[0].slice(0, -(fileExt[0].length - 45)) + "." + fileExt[1]; }

The oFile is read only, so you need to create a new json with the data. You cant change the name on the file.


contentType = oFile.type;
fileBlob = new Blob([oFile], {
	type: "application/octet-stream"
});
reader.readAsDataURL(fileBlob);
reader.onloadend = function() {
    fileBlobB64 = reader.result;
    b64file = fileBlobB64.split(",")[1];
}
file = { "docData": b64file, "extension": fileExt[1], "documentMimeType": contentType, "documentName": fileName, "size": oFile.size, "url": URL.createObjectURL(oFile) }


Answers (1)

Answers (1)

maheshpalavalli
Active Contributor
0 Kudos

Hi Hazal Oguce

I dont think uploadcollection has some functionality like that, but what you can do is, when you add the "slug"(filename) to the file that you are attaching in the change event, check if the file length exceeds, then you can change the file name and pass it to the "slug" parameter.

So you can turn off the file limit and handle it manually in the change event.

BR,

Mahesh

0 Kudos

Hi,

Thank you for getting back to me.I will try this.