Open sujeshshivan opened 4 years ago
Hello @sujeshshivan.
Nebular doesn't have yet a file uploader module, but you can use the prototype described in a not accepted pull request by @lexzhukov as I did. If you want to see how I applied this prototype component in my ngx-admin template, take a look in these two commits:
Steps to use:
// component.ts
export class MyComponent implements OnInit{
allowedMimeType: string[] = ['image/png','image/jpg']; // Change to what file types you need
fileTypesAllowed: string[];
maxFileSize = 2; // Change to max file size in mb
options: NbFileUploaderOptions;
...
ngOnInit() {
this.fileTypesAllowed = this.allowedMimeType.map((fileType: string) =>
fileType.substring(fileType.lastIndexOf('/') + 1, fileType.length)
);
options = {
url: 'http://localhost:3000',
multiple: false,
directory: false,
showUploadQueue: true,
allowedFileTypes: this.allowedMimeType,
filter: {
fn: (item: File) => {
if (item.size / 1024 / 1024 > this.maxFileSize) {
return false;
}
const itemType =
item.name.substring(
item.name.lastIndexOf('.') + 1,
item.name.length
) || item.name;
if (!this.fileTypesAllowed.includes(itemType)) {
return false;
}
return true;
},
},
};
}
...
<!-- component.html -->
...
<nb-file-uploader
[options]="options"
[isFileDrop]="true"
buttonLabel="Browse"
dropAreaLabel="Drag files here or"
dropAreaFileChooserLabel="browse to upload"
></nb-file-uploader>
...
P.S. In my implementation, drag'n'drop feature isn't reacting to nebular themes.
Issue type I'm submitting a feature request
Issue description Current behavior: There is no file uploader