Skip to content

Commit

Permalink
feat: add nextAppendPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
gxkl committed Oct 21, 2024
1 parent 54265de commit 9fbecde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/OSSBaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ export abstract class OSSBaseClient {
hostId = info.HostId;
}
err = new OSSClientError(status, info?.Code ?? 'Unknown', message, requestId, hostId);

// https://help.aliyun.com/zh/oss/support/http-status-code-409#section-rmc-hvd-j38
if (info?.Code === 'PositionNotEqualToLength' && result.headers['x-oss-next-append-position']) {
(err as any).nextAppendPosition = result.headers['x-oss-next-append-position'];
}
}

debug('generate error %o', err);
Expand Down
1 change: 1 addition & 0 deletions test/OSSObject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ describe('test/OSSObject.test.ts', () => {
assert.equal(err.name, 'OSSClientError');
assert.equal(err.code, 'PositionNotEqualToLength');
assert.equal(err.status, 409);
assert.equal((err as any).nextAppendPosition, '3');
assert.match(err.message, /Position is not equal to file length/);
return true;
});
Expand Down

0 comments on commit 9fbecde

Please sign in to comment.