ngx-uploader icon indicating copy to clipboard operation
ngx-uploader copied to clipboard

How to change file name

Open mdhanju opened this issue 7 years ago • 6 comments

"ngx-uploader": "^4.0.2",

mdhanju avatar Nov 09 '17 08:11 mdhanju

how do you mean how to change file name?

jkuri avatar Nov 09 '17 11:11 jkuri

User selects image with name IMAGE_26375.png But before uploading to server i want to change name to ca_21_profile.png

I tried, but this did't change file name

onUploadOutput(output: UploadOutput): void {
        if (output.type === 'addedToQueue' && typeof output.file !== 'undefined') {
              output.file.name = 'osritMy.png';
              this.files.push(output.file);
        }
}

mdhanju avatar Nov 09 '17 16:11 mdhanju

@mdhanju lets discuss a possible solution for that.

The only way I see is a filename template like 'ca_21_profile' as base name with a prefixed or suffixed hash to get identifiable files (eg: 1738456879_ca_21_profile.png, ca_21_profile_1738456879.png). A counter does'nt make sense, cause the files will be overwritten by the server (without a file handler on the server side). This can be implemented in NgUploaderService and we are needing an UploaderOption for that.

retailify avatar Nov 14 '17 10:11 retailify

I don't really get if the feature has been implemented in the release 4.x, because we're now in 6.x? If so, may I ask for a sample code, because @mdhanju is still not working?

F3L1X79 avatar Jul 12 '18 14:07 F3L1X79

changing the filename would indeed be useful, for example if the user uploads 4 files named 1.jpg and we rename them before uploading in order to prevent clashes

ganqqwerty avatar Jul 31 '18 14:07 ganqqwerty

Hi, using ngx-uploader 7.1.0 - any updates on this feature? We also have a need to prevent users from uploading the same filename multiple times.

mclear01 avatar Sep 10 '19 11:09 mclear01