Skip to content
Open
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: 6 additions & 6 deletions oss/source/custom-code/ossClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class OssClient extends BaseClient {
/**
* @deprecated Use the `uploadObject` method instead.
*/
public async uploadObjectAsync(bucketKey: string, objectKey: string, sourceToUpload: Buffer | string, optionalArgs?: { cancellationToken?: AbortController, requestIdPrefix?: string, accessToken?: string, onProgress?: (percentCompleted: number) => void }): Promise<ObjectDetails> {
public async uploadObjectAsync(bucketKey: string, objectKey: string, sourceToUpload: Buffer | string, optionalArgs?: { cancellationToken?: AbortController, requestIdPrefix?: string, accessToken?: string,xAdsMetaContentType?: string, xAdsMetaContentDisposition?: string, xAdsMetaContentEncoding?: string, xAdsMetaCacheControl?: string, onProgress?: (percentCompleted: number) => void }): Promise<ObjectDetails> {
if (!optionalArgs?.accessToken && !this.authenticationProvider) {
throw new Error("Please provide a valid access token or an authentication provider");
}
Expand All @@ -156,10 +156,10 @@ export class OssClient extends BaseClient {
var response;
if (typeof sourceToUpload === 'string') {
var buffer = await fs.readFile(sourceToUpload);
response = await this.ossFileTransfer.upload(bucketKey, objectKey, buffer, optionalArgs?.accessToken, optionalArgs?.cancellationToken || new AbortController, optionalArgs?.requestIdPrefix, optionalArgs?.onProgress);
response = await this.ossFileTransfer.upload(bucketKey, objectKey, buffer, optionalArgs?.accessToken, optionalArgs?.cancellationToken || new AbortController, optionalArgs?.requestIdPrefix, optionalArgs?.xAdsMetaContentType, optionalArgs?.xAdsMetaContentDisposition, optionalArgs?.xAdsMetaContentEncoding, optionalArgs?.xAdsMetaCacheControl, optionalArgs?.onProgress);
}
else {
response = await this.ossFileTransfer.upload(bucketKey, objectKey, sourceToUpload, optionalArgs?.accessToken, optionalArgs?.cancellationToken || new AbortController, optionalArgs?.requestIdPrefix, optionalArgs?.onProgress);
response = await this.ossFileTransfer.upload(bucketKey, objectKey, sourceToUpload, optionalArgs?.accessToken, optionalArgs?.cancellationToken || new AbortController, optionalArgs?.requestIdPrefix, optionalArgs?.xAdsMetaContentType, optionalArgs?.xAdsMetaContentDisposition, optionalArgs?.xAdsMetaContentEncoding, optionalArgs?.xAdsMetaCacheControl, optionalArgs?.onProgress);
}
return response.content;
}
Expand All @@ -177,7 +177,7 @@ export class OssClient extends BaseClient {
* @throws {RequiredError}
* @memberof OSSApiInterface
*/
public async uploadObject(bucketKey: string, objectKey: string, sourceToUpload: Buffer | string, optionalArgs?: { cancellationToken?: AbortController, requestIdPrefix?: string, accessToken?: string, onProgress?: (percentCompleted: number) => void }): Promise<ObjectDetails> {
public async uploadObject(bucketKey: string, objectKey: string, sourceToUpload: Buffer | string, optionalArgs?: { cancellationToken?: AbortController, requestIdPrefix?: string, accessToken?: string, xAdsMetaContentType?: string, xAdsMetaContentDisposition?: string, xAdsMetaContentEncoding?: string, xAdsMetaCacheControl?: string, onProgress?: (percentCompleted: number) => void }): Promise<ObjectDetails> {
if (!optionalArgs?.accessToken && !this.authenticationProvider) {
throw new Error("Please provide a valid access token or an authentication provider");
}
Expand All @@ -187,10 +187,10 @@ export class OssClient extends BaseClient {
var response;
if (typeof sourceToUpload === 'string') {
var buffer = await fs.readFile(sourceToUpload);
response = await this.ossFileTransfer.upload(bucketKey, objectKey, buffer, optionalArgs?.accessToken, optionalArgs?.cancellationToken || new AbortController, optionalArgs?.requestIdPrefix, optionalArgs?.onProgress);
response = await this.ossFileTransfer.upload(bucketKey, objectKey, buffer, optionalArgs?.accessToken, optionalArgs?.cancellationToken || new AbortController, optionalArgs?.requestIdPrefix, optionalArgs?.xAdsMetaContentType, optionalArgs?.xAdsMetaContentDisposition, optionalArgs?.xAdsMetaContentEncoding, optionalArgs?.xAdsMetaCacheControl, optionalArgs?.onProgress);
}
else {
response = await this.ossFileTransfer.upload(bucketKey, objectKey, sourceToUpload, optionalArgs?.accessToken, optionalArgs?.cancellationToken || new AbortController, optionalArgs?.requestIdPrefix, optionalArgs?.onProgress);
response = await this.ossFileTransfer.upload(bucketKey, objectKey, sourceToUpload, optionalArgs?.accessToken, optionalArgs?.cancellationToken || new AbortController, optionalArgs?.requestIdPrefix, optionalArgs?.xAdsMetaContentType, optionalArgs?.xAdsMetaContentDisposition, optionalArgs?.xAdsMetaContentEncoding, optionalArgs?.xAdsMetaCacheControl, optionalArgs?.onProgress);
}
return response.content;
}
Expand Down
9 changes: 7 additions & 2 deletions oss/source/custom-code/ossFileTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class OSSFileTransfer implements IOSSFileTransfer {
}
}

public async upload(bucketKey: string, objectKey: string, sourceToUpload: Buffer, accessToken: string, cancellationToken: AbortController,requestIdPrefix: string = '', onProgress?: (percentCompleted: number) => void): Promise<ApiResponse> {
public async upload(bucketKey: string, objectKey: string, sourceToUpload: Buffer, accessToken: string, cancellationToken: AbortController,requestIdPrefix: string = '', xAdsMetaContentType: string = '', xAdsMetaContentDisposition: string = '', xAdsMetaContentEncoding: string = '', xAdsMetaCacheControl: string = '', onProgress?: (percentCompleted: number) => void): Promise<ApiResponse> {
const requestId: any = await this.handleRequestId(requestIdPrefix, bucketKey, objectKey);
const retryCount: number = this.configuration.getRetryCount();
this.logger.logDebug(`${requestId} Config retry setting was: ${retryCount}`);
Expand Down Expand Up @@ -121,7 +121,12 @@ export class OSSFileTransfer implements IOSSFileTransfer {
"application/json",
{
uploadKey: uploadKey
} as Completes3uploadBody);
} as Completes3uploadBody,
xAdsMetaContentType,
xAdsMetaContentDisposition,
xAdsMetaContentEncoding,
xAdsMetaCacheControl
);
onProgress?.(100);
return completeResponse;
}
Expand Down