@@ -2,9 +2,7 @@ import is from '@sindresorhus/is'
2
2
import { createHmac } from 'crypto'
3
3
import { createReadStream } from 'fs'
4
4
import got , { Got , Options } from 'got'
5
- import { pipeline , Readable } from 'stream'
6
- import { finished } from 'stream/promises'
7
- import { promisify } from 'util'
5
+ import { Readable } from 'stream'
8
6
import { EnumStorageClass } from './constant'
9
7
import {
10
8
IFinishMultipartUploadRes , IGetMultiUploadIdRes , IHeadFileRes , IInitiateMultipartUploadRes , IListObjectsRes , IOptions ,
@@ -74,24 +72,12 @@ export class UFile {
74
72
*/
75
73
public async putFile ( key : string , file : Buffer | Readable | string ,
76
74
mimeType = defaultMimeType ) : Promise < void > {
77
- if ( is . buffer ( file ) || is . string ( file ) ) {
78
- await this . got . put ( key , {
79
- body : file ,
80
- headers : {
81
- 'content-type' : mimeType ,
82
- } ,
83
- } )
84
- } else if ( file instanceof Readable ) {
85
- const req = this . got . put ( key , {
86
- headers : {
87
- 'content-type' : mimeType ,
88
- } ,
89
- isStream : true ,
90
- } )
91
- const res = file . pipe ( req )
92
- await finished ( res )
93
- }
94
- throw new TypeError ( 'unknown file type' )
75
+ await this . got . put ( key , {
76
+ headers : {
77
+ 'content-type' : mimeType ,
78
+ } ,
79
+ body : file ,
80
+ } )
95
81
}
96
82
97
83
/**
0 commit comments