Skip to content

Commit

Permalink
fix: uploadPart cannot upload stream and etag error (#1334)
Browse files Browse the repository at this point in the history
  • Loading branch information
MilkChan01 authored Oct 25, 2024
1 parent e2a521c commit 40724aa
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 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 @@ -2649,25 +2648,24 @@ 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)
return {
etag: sanitizeETag(partRes.ETag),
etag: sanitizeETag(res.headers.etag),
key: objectName,
part: partNumber,
}
Expand Down

0 comments on commit 40724aa

Please sign in to comment.