Closed Aviico2 closed 1 year ago
for example add to constructor
this.uploads.subscribe(r => {
const completed = r.filter(u => u.status === 'complete');
console.log(completed); // completed uploads array
});
or
this.uploadService.events.subscribe(r => {
if (r.status === 'complete') {
console.log(r); // completed upload
}
});
Thanks @kukhariev It's working.
Ngx-upload Code:
uploads: Observable<Uploader[]>; options: UploadxOptions = { endpoint: 'http://localhost:4000/uploads', chunkSize: 1024 1024 5, metadata: { foldername: 'hello', }, autoUpload: false, };
constructor(public uploadService: UploadxService) { this.uploads = this.uploadService.connect(this.options); }
pause(): void { this.uploadService.control({ action: 'pause' }); }
upload(): void { this.uploadService.control({ action: 'upload' }); }
node-uploadx Code
const storage = new S3Storage({ endpoint: '', bucket: '', region: 'ap-south-1', apiVersion: '2006-03-01', credentials: { accessKeyId: '', secretAccessKey: '', }, forcePathStyle: true, expiration: { maxAge: '1h', purgeInterval: '15min' }, onComplete: file => { console.log('File upload complete: ', file) return file }, filename: (file) => file.metadata.foldername + '/' + file.originalName });
app.use('/uploads', uploadx({ storage }), function (req, res) { var file = req.body; console.log('File upload complete: ', file.originalName); res.send(file) });
How to handle response when the file is uploaded. Also with the multi-file upload.