Skip to content

Commit

Permalink
fix: uploadPart cannot upload stream and etag error
Browse files Browse the repository at this point in the history
  • Loading branch information
milkchan committed Aug 14, 2024
1 parent d08e54a commit 0ade4f6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/internal/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ import {
parseInitiateMultipart,
parseObjectLegalHoldConfig,
parseSelectObjectContentResponse,
uploadPartParser,
} from './xml-parser.ts'

const xml = new xml2js.Builder({ renderOpts: { pretty: false }, headless: true })
Expand Down Expand Up @@ -2641,25 +2640,26 @@ export class TypedClient {
return await this.copyObjectV2(source, dest)
}

async uploadPart(partConfig: {
bucketName: string
objectName: string
uploadID: string
partNumber: number
headers: RequestHeaders
}) {
async uploadPart(
partConfig: {
bucketName: string
objectName: string
uploadID: string
partNumber: number
headers: RequestHeaders
},
payload?: Binary,
) {
const { bucketName, objectName, uploadID, partNumber, headers } = partConfig

const method = 'PUT'
const query = `uploadId=${uploadID}&partNumber=${partNumber}`
const requestOptions = { method, bucketName, objectName: objectName, query, headers }

const res = await this.makeRequestAsync(requestOptions)
const body = await readAsString(res)
const partRes = uploadPartParser(body)

const res = await this.makeRequestAsync(requestOptions, payload)
// const body = await readAsString(res)
// const partRes = uploadPartParser(body)
return {
etag: sanitizeETag(partRes.ETag),
etag: sanitizeETag(res.headers.etag),
key: objectName,
part: partNumber,
}
Expand Down

0 comments on commit 0ade4f6

Please sign in to comment.