zefoy / ngx-dropzone-wrapper

Angular wrapper library for Dropzone
MIT License
174 stars 51 forks source link

Uploading to S3 #39

Closed iamjsmith closed 7 years ago

iamjsmith commented 7 years ago

I'm trying to figure out how to dynamically change the url on processing event to an S3 signed url. I've done this before with Dropzone directly but can't seem to do this with the wrapper. Any help would be greatly appreciated.

sconix commented 7 years ago

It should not be any different with this library than with Dropzone directly. Can you be bit more specific that what is the problem?

iamjsmith commented 7 years ago

Sure. So when the file is processing I need to dynamically change the url before dropzone tries to upload. In Angular 1 I would do it like this:

processing:function(file){ this.options.url = file.signedRequest; }

I can't figure out where this would go or how to change the config anyway

sconix commented 7 years ago

Ok, passing the function is the easy part. You just define the processing function in the config object.

Changing the url is bit tricky since changing the configuration will cause change detection to "reset" Dropzone since Dropzone does not really support dynamic configuration changing (for some it works, but not for all) so thats why this library reset Dropzone on config changes. But you should be able to change the url directly in the Dropzone object, so just access the Dropzone through the directive reference (using ViewChild). The Dropzone is exposed as 'dropzone' within the directive so you can set the url by directiveRef.dropzone.options.url = file.signedRequest. Or if you are using component then the directiveRef is available through the componentRef (componentRef.directiveRef.dropzone.options.url).

At least I am 99% sure that it should work :)

murilobd commented 7 years ago

I was struggling with this issue as well but followed instructions from @sconix and worked out! Nice!