how new FileItem through JSON? #1000

Open
opened 2018-03-29 10:06:37 +00:00 by HotEvent · 1 comment
HotEvent commented 2018-03-29 10:06:37 +00:00 (Migrated from github.com)

I have a json like
{name:'somefile',url:'someurl'}
I try use let fileItem = new FileItem(this.uploader,null,{})but I get error
how get a FileItem instance?

I have a json like `{name:'somefile',url:'someurl'}` I try use `let fileItem = new FileItem(this.uploader,null,{})`but I get error how get a FileItem instance?
koenvanderlinden commented 2018-03-29 13:20:32 +00:00 (Migrated from github.com)

You should replace your null value with a File object. A File object can be taken from a FileInput controle.
You should check the sample application, it shows how to use a select-directive and file-drop directive. These two handles the FileInput/Drop control -> File -> FileItem -> a queue for uploading with the upload control.

If you want to create a File from some data you could do it like this:

let someFile: File = new File(["some content for the filename comes here"], "someFileName.txt");
this.uploader.addToQueue(new Array<File>(someFile));
this.uploader.uploadAll();

If you want to upload a url from some external location, you should first need to download that data to the client and create a File from that data.

You should replace your null value with a File object. A File object can be taken from a FileInput controle. You should check the sample application, it shows how to use a select-directive and file-drop directive. These two handles the FileInput/Drop control -> File -> FileItem -> a queue for uploading with the upload control. If you want to create a File from some data you could do it like this: ``` let someFile: File = new File(["some content for the filename comes here"], "someFileName.txt"); this.uploader.addToQueue(new Array<File>(someFile)); this.uploader.uploadAll(); ``` If you want to upload a url from some external location, you should first need to download that data to the client and create a File from that data.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#1000