diff --git a/dev/server.js b/dev/server.js index 1477e3ec..7ec1e065 100644 --- a/dev/server.js +++ b/dev/server.js @@ -90,7 +90,7 @@ class ServerExample { responseJson.success = 1; responseJson.file = { - url: image.filepath, + url: 'file://' + image.filepath, name: image.newFilename, size: image.size }; diff --git a/src/types/types.ts b/src/types/types.ts index f4b564f6..53945d7c 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -117,12 +117,12 @@ export interface ImageConfig { /** * Field name for the uploaded image. */ - field?: string; + field: string; /** * Allowed mime-types for the uploaded image. */ - types?: string; + types: string; /** * Placeholder text for the caption field. diff --git a/src/uploader.ts b/src/uploader.ts index 3f456ba9..006b4690 100644 --- a/src/uploader.ts +++ b/src/uploader.ts @@ -72,7 +72,7 @@ export default class Uploader { // custom uploading if (this.config.uploader && typeof this.config.uploader.uploadByFile === 'function') { const uploadByFile = this.config.uploader.uploadByFile; - upload = ajax.selectFiles({ accept: this.config.types || 'image/*'}).then((files: File[]) => { + upload = ajax.selectFiles({ accept: this.config.types}).then((files: File[]) => { preparePreview(files[0]); const customUpload = uploadByFile(files[0]); @@ -181,7 +181,7 @@ export default class Uploader { */ const formData = new FormData(); - formData.append(this.config.field || 'image', file); + formData.append(this.config.field, file); if (this.config.additionalRequestData && Object.keys(this.config.additionalRequestData).length) { Object.entries(this.config.additionalRequestData).forEach(([name, value]: [string, any]) => {