Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/upload/src/upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,16 @@ export default {
const fileType = Object.prototype.toString.call(processedFile);

if (fileType === '[object File]' || fileType === '[object Blob]') {
processedFile.name = rawFile.name;
processedFile.uid = rawFile.uid;
if (fileType === '[object Blob]') {
processedFile = new File([processedFile], rawFile.name, {
type: rawFile.type
});
}
for (const p in rawFile) {
if (rawFile.hasOwnProperty(p)) {
processedFile[p] = rawFile[p];
}
}
this.post(processedFile);
} else {
this.post(rawFile);
Expand Down
8 changes: 6 additions & 2 deletions types/upload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ export interface FileListItem {
status?: FileUploadStatus
}

export interface ElUploadInternalRawFile extends File {
uid: number
}

export interface ElUploadInternalFileDetail {
status: FileUploadStatus,
name: string,
size: number,
percentage: number,
uid: number,
raw: File,
raw: ElUploadInternalRawFile,
url?: string
}

Expand Down Expand Up @@ -83,7 +87,7 @@ export declare class ElUpload extends ElementUIComponent {
onChange: (file: ElUploadInternalFileDetail, fileList: ElUploadInternalFileDetail[]) => void

/** Hook function before uploading with the file to be uploaded as its parameter. If false or a Promise is returned, uploading will be aborted */
beforeUpload: (file: ElUploadInternalFileDetail) => boolean | Promise<File | boolean>
beforeUpload: (file: ElUploadInternalRawFile) => boolean | Promise<File | Blob | boolean>

/** Whether thumbnail is displayed */
thumbnailMode: boolean
Expand Down