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
7 changes: 6 additions & 1 deletion oss/source/custom-code/IOSSFileTransfer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ Task<HttpResponseMessage> Upload(
string accessToken,
CancellationToken cancellationToken,
string requestIdPrefix = "",
IProgress<int> progress = null);
IProgress<int> progress = null,
string xAdsMetaContentType = default(string),
string xAdsMetaContentDisposition = default(string),
string xAdsMetaContentEncoding = default(string),
string xAdsMetaCacheControl = default(string),
string xAdsUserDefinedMetadata = default(string));

Task<Stream> Download(
string bucketKey,
Expand Down
14 changes: 12 additions & 2 deletions oss/source/custom-code/OSSFileTransfer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ public async Task<HttpResponseMessage> Upload(
string accessToken,
CancellationToken cancellationToken,
string requestIdPrefix = "",
IProgress<int> progress = null)
IProgress<int> progress = null,
string xAdsMetaContentType = default(string),
string xAdsMetaContentDisposition = default(string),
string xAdsMetaContentEncoding = default(string),
string xAdsMetaCacheControl = default(string),
string xAdsUserDefinedMetadata = default(string))
{
var requestId = HandleRequestId(requestIdPrefix, bucketKey, objectKey);
var retryCount = _configuration.GetRetryCount();
Expand Down Expand Up @@ -226,7 +231,12 @@ public async Task<HttpResponseMessage> Upload(
{
UploadKey = uploadKey
},
accessToken: accessToken);
accessToken: accessToken,
xAdsMetaContentType: xAdsMetaContentType,
xAdsMetaContentDisposition: xAdsMetaContentDisposition,
xAdsMetaContentEncoding: xAdsMetaContentEncoding,
xAdsMetaCacheControl: xAdsMetaCacheControl,
xAdsUserDefinedMetadata: xAdsUserDefinedMetadata);

progress?.Report(100);
return completeResponse;
Expand Down
40 changes: 35 additions & 5 deletions oss/source/custom-code/OssClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,23 @@ public OssClient(SDKManager.SDKManager sdkManager = default, IAuthenticationProv
/// An access token obtained by a call to GetThreeLeggedTokenAsync() or GetTwoLeggedTokenAsync().
/// (optional)
/// </param>
/// <param name="xAdsMetaContentType">
///The Content-Type value for the uploaded object to record within OSS. (optional)
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML documentation comments are missing proper spacing. Each comment should start with '/// ' (three slashes followed by a space) instead of '///'.

Copilot uses AI. Check for mistakes.

/// </param>
/// <param name="xAdsMetaContentDisposition">
///The Content-Disposition value for the uploaded object to record within OSS. (optional)
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML documentation comments are missing proper spacing. Each comment should start with '/// ' (three slashes followed by a space) instead of '///'.

Copilot uses AI. Check for mistakes.

/// </param>
/// <param name="xAdsMetaContentEncoding">
///The Content-Encoding value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaCacheControl">
///The Cache-Control value for the uploaded object to record within OSS. (optional)
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML documentation comments are missing proper spacing. Each comment should start with '/// ' (three slashes followed by a space) instead of '///'.

Suggested change
///The Cache-Control value for the uploaded object to record within OSS. (optional)
/// The Cache-Control value for the uploaded object to record within OSS. (optional)

Copilot uses AI. Check for mistakes.

/// </param>
/// <param name="xAdsUserDefinedMetadata">
///Custom metadata to be stored with the object, which can be retrieved later on download or when retrieving object details. Must be a JSON object that is less than 100 bytes. (optional)
Comment on lines +84 to +96
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML documentation comments are missing proper spacing. Each comment should start with '/// ' (three slashes followed by a space) instead of '///'.

Suggested change
///The Content-Type value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentDisposition">
///The Content-Disposition value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentEncoding">
///The Content-Encoding value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaCacheControl">
///The Cache-Control value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsUserDefinedMetadata">
///Custom metadata to be stored with the object, which can be retrieved later on download or when retrieving object details. Must be a JSON object that is less than 100 bytes. (optional)
/// The Content-Type value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentDisposition">
/// The Content-Disposition value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentEncoding">
/// The Content-Encoding value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaCacheControl">
/// The Cache-Control value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsUserDefinedMetadata">
/// Custom metadata to be stored with the object, which can be retrieved later on download or when retrieving object details. Must be a JSON object that is less than 100 bytes. (optional)

Copilot uses AI. Check for mistakes.

/// </param>
/// <returns>Task of &lt;Upload&gt;</returns>
public async System.Threading.Tasks.Task<ObjectDetails> UploadObjectAsync(string bucketKey, string objectKey, Stream sourceToUpload, CancellationToken cancellationToken = default, string requestIdPrefix = "", IProgress<int> progress = null, string accessToken = default)
public async System.Threading.Tasks.Task<ObjectDetails> UploadObjectAsync(string bucketKey, string objectKey, Stream sourceToUpload, CancellationToken cancellationToken = default, string requestIdPrefix = "", IProgress<int> progress = null, string accessToken = default, string xAdsMetaContentType = default(string), string xAdsMetaContentDisposition = default(string), string xAdsMetaContentEncoding = default(string), string xAdsMetaCacheControl = default(string), string xAdsUserDefinedMetadata = default(string))
{
if (String.IsNullOrEmpty(accessToken) && this.AuthenticationProvider == null)
{
Expand All @@ -91,7 +106,7 @@ public async System.Threading.Tasks.Task<ObjectDetails> UploadObjectAsync(string
{
accessToken = await this.AuthenticationProvider.GetAccessToken();
}
var response = await this.oSSFileTransfer.Upload(bucketKey, objectKey, sourceToUpload, accessToken, cancellationToken, requestIdPrefix, progress);
var response = await this.oSSFileTransfer.Upload(bucketKey, objectKey, sourceToUpload, accessToken, cancellationToken, requestIdPrefix, progress, xAdsMetaContentType,xAdsMetaContentDisposition, xAdsMetaContentEncoding, xAdsMetaCacheControl, xAdsUserDefinedMetadata);
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma between xAdsMetaContentType and xAdsMetaContentDisposition parameters. This should be consistent with the spacing used for other parameters.

Suggested change
var response = await this.oSSFileTransfer.Upload(bucketKey, objectKey, sourceToUpload, accessToken, cancellationToken, requestIdPrefix, progress, xAdsMetaContentType,xAdsMetaContentDisposition, xAdsMetaContentEncoding, xAdsMetaCacheControl, xAdsUserDefinedMetadata);
var response = await this.oSSFileTransfer.Upload(bucketKey, objectKey, sourceToUpload, accessToken, cancellationToken, requestIdPrefix, progress, xAdsMetaContentType, xAdsMetaContentDisposition, xAdsMetaContentEncoding, xAdsMetaCacheControl, xAdsUserDefinedMetadata);

Copilot uses AI. Check for mistakes.

var apiResponse = new ApiResponse<ObjectDetails>(response, await LocalMarshalling.DeserializeAsync<ObjectDetails>(response.Content));
return apiResponse.Content;
}
Expand Down Expand Up @@ -128,9 +143,24 @@ public async System.Threading.Tasks.Task<ObjectDetails> UploadObjectAsync(string
/// An access token obtained by a call to GetThreeLeggedTokenAsync() or GetTwoLeggedTokenAsync().
/// (optional)
/// </param>
/// <param name="xAdsMetaContentType">
///The Content-Type value for the uploaded object to record within OSS. (optional)
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML documentation comments are missing proper spacing. Each comment should start with '/// ' (three slashes followed by a space) instead of '///'.

Suggested change
///The Content-Type value for the uploaded object to record within OSS. (optional)
/// The Content-Type value for the uploaded object to record within OSS. (optional)

Copilot uses AI. Check for mistakes.

/// </param>
/// <param name="xAdsMetaContentDisposition">
///The Content-Disposition value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentEncoding">
///The Content-Encoding value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaCacheControl">
///The Cache-Control value for the uploaded object to record within OSS. (optional)
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML documentation comments are missing proper spacing. Each comment should start with '/// ' (three slashes followed by a space) instead of '///'.

Suggested change
///The Cache-Control value for the uploaded object to record within OSS. (optional)
/// The Cache-Control value for the uploaded object to record within OSS. (optional)

Copilot uses AI. Check for mistakes.

/// </param>
/// <param name="xAdsUserDefinedMetadata">
///Custom metadata to be stored with the object, which can be retrieved later on download or when retrieving object details. Must be a JSON object that is less than 100 bytes. (optional)
Comment on lines +147 to +159
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML documentation comments are missing proper spacing. Each comment should start with '/// ' (three slashes followed by a space) instead of '///'.

Suggested change
///The Content-Type value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentDisposition">
///The Content-Disposition value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentEncoding">
///The Content-Encoding value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaCacheControl">
///The Cache-Control value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsUserDefinedMetadata">
///Custom metadata to be stored with the object, which can be retrieved later on download or when retrieving object details. Must be a JSON object that is less than 100 bytes. (optional)
/// The Content-Type value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentDisposition">
/// The Content-Disposition value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentEncoding">
/// The Content-Encoding value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaCacheControl">
/// The Cache-Control value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsUserDefinedMetadata">
/// Custom metadata to be stored with the object, which can be retrieved later on download or when retrieving object details. Must be a JSON object that is less than 100 bytes. (optional)

Copilot uses AI. Check for mistakes.

Comment on lines +147 to +159
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML documentation comments are missing proper spacing. Each comment should start with '/// ' (three slashes followed by a space) instead of '///'.

Suggested change
///The Content-Type value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentDisposition">
///The Content-Disposition value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentEncoding">
///The Content-Encoding value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaCacheControl">
///The Cache-Control value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsUserDefinedMetadata">
///Custom metadata to be stored with the object, which can be retrieved later on download or when retrieving object details. Must be a JSON object that is less than 100 bytes. (optional)
/// The Content-Type value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentDisposition">
/// The Content-Disposition value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaContentEncoding">
/// The Content-Encoding value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsMetaCacheControl">
/// The Cache-Control value for the uploaded object to record within OSS. (optional)
/// </param>
/// <param name="xAdsUserDefinedMetadata">
/// Custom metadata to be stored with the object, which can be retrieved later on download or when retrieving object details. Must be a JSON object that is less than 100 bytes. (optional)

Copilot uses AI. Check for mistakes.

/// </param>
/// <returns>Task of &lt;Upload&gt;</returns>
public async System.Threading.Tasks.Task<ObjectDetails> UploadObjectAsync(string bucketKey, string objectKey, string sourceToUpload, CancellationToken cancellationToken = default, string requestIdPrefix = "", IProgress<int> progress = null, string accessToken = default)
{
public async System.Threading.Tasks.Task<ObjectDetails> UploadObjectAsync(string bucketKey, string objectKey, string sourceToUpload, CancellationToken cancellationToken = default, string requestIdPrefix = "", IProgress<int> progress = null, string accessToken = default, string xAdsMetaContentType = default(string), string xAdsMetaContentDisposition = default(string), string xAdsMetaContentEncoding = default(string), string xAdsMetaCacheControl = default(string), string xAdsUserDefinedMetadata = default(string))
{
if (String.IsNullOrEmpty(accessToken) && this.AuthenticationProvider == null)
{
throw new Exception("Please provide a valid access token or an authentication provider");
Expand All @@ -141,7 +171,7 @@ public async System.Threading.Tasks.Task<ObjectDetails> UploadObjectAsync(string
}

FileStream fileStream = File.OpenRead(sourceToUpload);
var response = await this.oSSFileTransfer.Upload(bucketKey, objectKey, fileStream, accessToken, cancellationToken, requestIdPrefix, progress);
var response = await this.oSSFileTransfer.Upload(bucketKey, objectKey, fileStream, accessToken, cancellationToken, requestIdPrefix, progress, xAdsMetaContentType, xAdsMetaContentDisposition, xAdsMetaContentEncoding, xAdsMetaCacheControl, xAdsUserDefinedMetadata);
var apiResponse = new ApiResponse<ObjectDetails>(response, await LocalMarshalling.DeserializeAsync<ObjectDetails>(response.Content));
return apiResponse.Content;
}
Expand Down
32 changes: 30 additions & 2 deletions oss/test/TestOss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ public class TestOss
string? filePath = Environment.GetEnvironmentVariable("FILE_PATH");
// Signed Url Format: "https://developer.api.autodesk.com/oss/v2/signedresources/<hash>?region=US"
string? signedUrl = Environment.GetEnvironmentVariable("SIGNED_URL");
string? xAdsMetaContentType = Environment.GetEnvironmentVariable("XADS_META_CONTENT_TYPE");
string? xAdsMetaContentDisposition = Environment.GetEnvironmentVariable("XADS_META_CONTENT_DISPOSITION");
string? xAdsMetaContentEncoding = Environment.GetEnvironmentVariable("XADS_META_CONTENT_ENCODING");
string? xAdsMetaCacheControl = Environment.GetEnvironmentVariable("XADS_META_CACHE_CONTROL");
string? xAdsUserDefinedMetadata = Environment.GetEnvironmentVariable("XADS_USER_DEFINED_METADATA");

[ClassInitialize]
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
var sdkManager = SdkManagerBuilder
Expand Down Expand Up @@ -84,7 +89,30 @@ public async Task TestUploadObjectAsync()
bucketKey: bucketKey,
objectKey: objectKey,
sourceToUpload: sourceToUpload,
cancellationToken: CancellationToken.None);
cancellationToken: CancellationToken.None,
xAdsMetaContentType: xAdsMetaContentType,
xAdsMetaContentDisposition: xAdsMetaContentDisposition,
xAdsMetaContentEncoding: xAdsMetaContentEncoding,
xAdsMetaCacheControl: xAdsMetaCacheControl,
xAdsUserDefinedMetadata: xAdsUserDefinedMetadata);
Assert.IsTrue(objectDetails.ObjectId.Equals($"urn:adsk.objects:os.object:{bucketKey}/{objectKey}"));
}

[TestMethod]
public async Task TestUploadObjectStreamAsync()
{
using var fileStream = File.OpenRead(sourceToUpload);
ObjectDetails objectDetails = await _ossClient.UploadObjectAsync(
accessToken: token,
bucketKey: bucketKey,
objectKey: objectKey,
sourceToUpload: fileStream,
cancellationToken: CancellationToken.None,
xAdsMetaContentType: xAdsMetaContentType,
xAdsMetaContentDisposition: xAdsMetaContentDisposition,
xAdsMetaContentEncoding: xAdsMetaContentEncoding,
xAdsMetaCacheControl: xAdsMetaCacheControl,
xAdsUserDefinedMetadata: xAdsUserDefinedMetadata);
Assert.IsTrue(objectDetails.ObjectId.Equals($"urn:adsk.objects:os.object:{bucketKey}/{objectKey}"));
}

Expand Down