How to add uploaded files to uplaoder queue #741

Open
opened 2017-04-11 02:08:23 +00:00 by juntaforce · 6 comments
juntaforce commented 2017-04-11 02:08:23 +00:00 (Migrated from github.com)

Im using Firebase storage as backend to save files.
And then I need to preparing an update form to update content and content's files.
So I can get uploaded files metadata from Firebase as an object (name, size, type, serverURL,etc..) then I need to push these files to Uploader.queue again.

How can achieve this without fileinput and dropzone area to add files to Uploader queue ??

Im using Firebase storage as backend to save files. And then I need to preparing an update form to update content and content's files. So I can get uploaded files metadata from Firebase as an object (name, size, type, serverURL,etc..) then I need to push these files to Uploader.queue again. How can achieve this without fileinput and dropzone area to add files to Uploader queue ??
juntaforce commented 2017-04-13 03:26:55 +00:00 (Migrated from github.com)
  this.post = this.af.database.object(`/Posts/${id}`);
  this.post.subscribe(snapshot =>       
  this.uploadImagesService.getMetaData(snapshot.postpicurl).subscribe((metadata:any) =>{
    files[0].name = metadata.name;
    files[0].size = metadata.size;
    console.log(files[0].name);
    files[0].type = metadata.contentType;
    this.uploader.addToQueue(files);
 });

message: 'Cannot assign to 'size' because it is a constant or a read-only property.'

Has anyone ever encountered such kind of problem?
I just want to add file items to queue on page load ??

this.post = this.af.database.object(`/Posts/${id}`); this.post.subscribe(snapshot => this.uploadImagesService.getMetaData(snapshot.postpicurl).subscribe((metadata:any) =>{ files[0].name = metadata.name; files[0].size = metadata.size; console.log(files[0].name); files[0].type = metadata.contentType; this.uploader.addToQueue(files); }); message: 'Cannot assign to 'size' because it is a constant or a read-only property.' Has anyone ever encountered such kind of problem? I just want to add file items to queue on page load ??
shamanth7077 commented 2017-06-14 10:06:46 +00:00 (Migrated from github.com)

@juntaforce have you solved this problem? I am trying to achieve the same thing, on page load I need to load a file from server and add it to the uploader queue.

@juntaforce have you solved this problem? I am trying to achieve the same thing, on page load I need to load a file from server and add it to the uploader queue.
AlexObreja commented 2017-06-22 07:33:55 +00:00 (Migrated from github.com)

Any one solved this?

Any one solved this?
shamanth7077 commented 2017-06-22 09:05:36 +00:00 (Migrated from github.com)

I have implemented as below and it works.

uploader:FileUploader = new FileUploader({url: ''});

this.articleservice.downloadPDF(this.ArticleID).subscribe(
       (res) => {     
               let files : Array<File> = []; 
               file = new File([res], filename , {type: res.type}); 
               files.push(file);
               this.uploader.addToQueue(files);
               this.pdfFileBlob = file;
           }
       );
downloadPDF(articleid): any {
       return this.http.get(requestUrl, { responseType: ResponseContentType.Blob })
        .map((res) => {
            return new Blob([res.blob()], { type: res.blob().type });
        })
    }
I have implemented as below and it works. `uploader:FileUploader = new FileUploader({url: ''});` ``` this.articleservice.downloadPDF(this.ArticleID).subscribe( (res) => { let files : Array<File> = []; file = new File([res], filename , {type: res.type}); files.push(file); this.uploader.addToQueue(files); this.pdfFileBlob = file; } ); ``` ``` downloadPDF(articleid): any { return this.http.get(requestUrl, { responseType: ResponseContentType.Blob }) .map((res) => { return new Blob([res.blob()], { type: res.blob().type }); }) } ```
AlexObreja commented 2017-06-25 07:01:16 +00:00 (Migrated from github.com)

Hi @shamanth7077 , thank you very much for sharing your code. I have used ng2-dragula to manage the uploaded files. With dragula i can order them with a great drag and drop, but this is a great solution. i think i'll implement this too..

Hi @shamanth7077 , thank you very much for sharing your code. I have used ng2-dragula to manage the uploaded files. With dragula i can order them with a great drag and drop, but this is a great solution. i think i'll implement this too..
Sachin-Suresh commented 2017-07-25 11:34:14 +00:00 (Migrated from github.com)

Hi @shamanth7077 , if the file uploaded is working, could you please help us, we are getting Can't bind to 'uploader' since it isn't a known property of 'input' error even after importing all the necessary modules in app module. I have explained in the issue post here: https://github.com/valor-software/ng2-file-upload/issues/852 would be helpful if u tell us how you got it workin!!

Hi @shamanth7077 , if the file uploaded is working, could you please help us, we are getting Can't bind to 'uploader' since it isn't a known property of 'input' error even after importing all the necessary modules in app module. I have explained in the issue post here: https://github.com/valor-software/ng2-file-upload/issues/852 would be helpful if u tell us how you got it workin!!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#741