Simple-Demo : what is "remove" supposed to do ? #301

Open
opened 2016-07-12 07:56:46 +00:00 by samfrach · 5 comments
samfrach commented 2016-07-12 07:56:46 +00:00 (Migrated from github.com)

Hello,

I don't see any server call when I click on REMOVE or REMOVE-ALL. Isn't it supposed to notify the server to remove the upload file ?

Do you have a more complete demo (or docs ?) ?

thank you

Hello, I don't see any server call when I click on REMOVE or REMOVE-ALL. Isn't it supposed to notify the server to remove the upload file ? Do you have a more complete demo (or docs ?) ? thank you
t246246 commented 2016-07-12 12:54:39 +00:00 (Migrated from github.com)

Remove means remove from queue.

Remove means remove from queue.
samfrach commented 2016-07-14 06:45:35 +00:00 (Migrated from github.com)

in that case, why is it still possible to remove a file once it has been uploaded ? It makes no sense.

thank you

in that case, why is it still possible to remove a file once it has been uploaded ? It makes no sense. thank you
t246246 commented 2016-07-14 07:13:00 +00:00 (Migrated from github.com)

You can also remove the file from queue before uploading. If you want to remove file from queue automatically after upload, you may set removeAfterUpload option to true.

22307d266f/components/file-upload/file-uploader.class.ts (L29)

You can also remove the file from queue before uploading. If you want to remove file from queue automatically after upload, you may set removeAfterUpload option to true. https://github.com/valor-software/ng2-file-upload/blob/22307d266fe1a25e109e9315515ca05156e38591/components/file-upload/file-uploader.class.ts#L29
railslauncher commented 2016-12-24 07:25:21 +00:00 (Migrated from github.com)

We need some callback like onAfterRemoveItem where we can send API call to remove the uploaded file.
We can skip the remove API call if the file not yet uploaded.

We need some callback like onAfterRemoveItem where we can send API call to remove the uploaded file. We can skip the remove API call if the file not yet uploaded.
JanCizmar commented 2017-03-27 18:23:56 +00:00 (Migrated from github.com)

I solved it like this

 ngOnInit() {
        this.uploader.onAfterAddingFile = ((value) => {
            value.withCredentials = false;
            this.uploader.setOptions({
                url: AppModule.API_URL + 'imageUpload',
                authToken: this.getToken()
            });
            value.upload();

            let name;

            value.onSuccess = (res) => {
                name = JSON.parse(res);
            };

            value.remove = () => {
                this.http.delete(AppModule.API_URL + 'delete/' + name).subscribe((res) => {
                    var index: number = this.uploader.queue.indexOf(value, 0);
                    if (index > -1) {
                        this.uploader.queue.splice(index, 1);
                    }
                });
            };

        })
    }
I solved it like this ``` ngOnInit() { this.uploader.onAfterAddingFile = ((value) => { value.withCredentials = false; this.uploader.setOptions({ url: AppModule.API_URL + 'imageUpload', authToken: this.getToken() }); value.upload(); let name; value.onSuccess = (res) => { name = JSON.parse(res); }; value.remove = () => { this.http.delete(AppModule.API_URL + 'delete/' + name).subscribe((res) => { var index: number = this.uploader.queue.indexOf(value, 0); if (index > -1) { this.uploader.queue.splice(index, 1); } }); }; }) } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#301