Skip to content

Commit 8aa1c75

Browse files
authored
Add support for ResourceType from Context Upload API
1 parent 58b4962 commit 8aa1c75

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

CloudinaryDotNet.IntegrationTests/UploadApi/ContextMethodsTest.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,35 @@ public void TestContext()
8383
Assert.AreEqual("value", res?.Context["custom"]?["key"]?.ToString(), res.Error?.Message);
8484
Assert.AreEqual("value2", res?.Context["custom"]?["key2"]?.ToString());
8585
}
86+
87+
[Test, RetryWithDelay]
88+
public void TestAddVideoContext()
89+
{
90+
var publicId = GetUniquePublicId();
91+
92+
var uploadParams = new VideoUploadParams
93+
{
94+
File = new FileDescription(m_testVideoPath),
95+
PublicId = publicId,
96+
Overwrite = true,
97+
Type = STORAGE_TYPE_UPLOAD,
98+
Tags = m_apiTag
99+
};
100+
101+
m_cloudinary.Upload(uploadParams);
102+
103+
List<string> pIds = new List<string> { publicId };
104+
105+
ContextResult contextResult = m_cloudinary.Context(new ContextParams()
106+
{
107+
Command = ContextCommand.Add,
108+
PublicIds = pIds,
109+
Type = STORAGE_TYPE_UPLOAD,
110+
Context = "TestContext",
111+
ResourceType = ResourceType.Video
112+
});
113+
114+
Assert.True(contextResult.PublicIds.Length > 0, contextResult.Error?.Message);
115+
}
86116
}
87117
}

CloudinaryDotNet/Cloudinary.UploadApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ public TagResult Tag(TagParams parameters)
468468
/// <returns>Results of contexts management.</returns>
469469
public Task<ContextResult> ContextAsync(ContextParams parameters, CancellationToken? cancellationToken = null)
470470
{
471-
string uri = m_api.ApiUrlImgUpV.Action(Constants.CONTEXT_MANAGMENT).BuildUrl();
471+
string uri = m_api.ApiUrlImgUpV.ResourceType(ApiShared.GetCloudinaryParam(parameters.ResourceType)).Action(Constants.CONTEXT_MANAGMENT).BuildUrl();
472472

473473
return CallUploadApiAsync<ContextResult>(
474474
HttpMethod.POST,

0 commit comments

Comments
 (0)