Skip to content

Commit b637e9d

Browse files
Add support for Dynamic Folders parameters in Explicit Upload API
1 parent 858c1b9 commit b637e9d

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

CloudinaryDotNet.Tests/Parameters/ParametersTest.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void TestImageUploadParamsDictionary()
175175
}
176176

177177
[Test]
178-
public void TestUploadFolderDecouplingParamsCheck()
178+
public void TestUploadDynamicFoldersParamsCheck()
179179
{
180180
var parameters = new ImageUploadParams
181181
{
@@ -197,6 +197,25 @@ public void TestUploadFolderDecouplingParamsCheck()
197197
Assert.AreEqual("folder", dictionary["folder"]);
198198
}
199199

200+
[Test]
201+
public void TestExplicitDynamicFoldersParamsCheck()
202+
{
203+
var parameters = new ExplicitParams("test_id")
204+
{
205+
PublicIdPrefix = "fd_public_id_prefix",
206+
DisplayName = "test",
207+
UseFilenameAsDisplayName = true,
208+
AssetFolder = "asset_folder"
209+
};
210+
211+
var dictionary = parameters.ToParamsDictionary();
212+
213+
Assert.AreEqual("fd_public_id_prefix", dictionary["public_id_prefix"]);
214+
Assert.AreEqual("test", dictionary["display_name"]);
215+
Assert.AreEqual("true", dictionary["use_filename_as_display_name"]);
216+
Assert.AreEqual("asset_folder", dictionary["asset_folder"]);
217+
}
218+
200219
[Test]
201220
public void TestExplicitParamsDictionary()
202221
{

CloudinaryDotNet/Actions/AssetsUpload/ExplicitParams.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ public ExplicitParams(string publicId)
6868
/// </summary>
6969
public string PublicId { get; set; }
7070

71+
/// <summary>
72+
/// Gets or sets the identifier that is used to provide context and to improve the SEO of an assets filename in the delivery URL.
73+
/// It does not impact the location where the asset is stored.
74+
/// </summary>
75+
public string PublicIdPrefix { get; set; }
76+
7177
/// <summary>
7278
/// Gets or sets an HTTP header or a list of headers lines for returning as response HTTP headers when delivering the
7379
/// uploaded image to your users. Supported headers: 'Link', 'X-Robots-Tag'.
@@ -81,6 +87,24 @@ public ExplicitParams(string publicId)
8187
/// </summary>
8288
public string Tags { get; set; }
8389

90+
/// <summary>
91+
/// Gets or sets the name that is displayed for the asset in the Media Library.
92+
/// This value does not impact the asset’s Public ID.
93+
/// </summary>
94+
public string DisplayName { get; set; }
95+
96+
/// <summary>
97+
/// Gets or sets whether to automatically assign the filename of the uploaded asset as the asset’s display name in the Media Library.
98+
/// Relevant only if <see cref="DisplayName"/> is not passed.
99+
/// </summary>
100+
public bool? UseFilenameAsDisplayName { get; set; }
101+
102+
/// <summary>
103+
/// Gets or sets the folder where the asset is stored in the Media Library.
104+
/// This value does not impact the asset’s Public ID.
105+
/// </summary>
106+
public string AssetFolder { get; set; }
107+
84108
/// <summary>
85109
/// Gets or sets the coordinates of faces contained in an uploaded image and overrides the automatically detected
86110
/// faces.
@@ -233,6 +257,7 @@ public override SortedDictionary<string, object> ToParamsDictionary()
233257
var dict = base.ToParamsDictionary();
234258

235259
AddParam(dict, "public_id", PublicId);
260+
AddParam(dict, "public_id_prefix", PublicIdPrefix);
236261
AddParam(dict, "tags", Tags);
237262
AddParam(dict, "type", Type);
238263
AddParam(dict, "ocr", Ocr);
@@ -248,6 +273,9 @@ public override SortedDictionary<string, object> ToParamsDictionary()
248273
AddParam(dict, "quality_override", QualityOverride);
249274
AddParam(dict, "moderation", Moderation);
250275
AddParam(dict, "accessibility_analysis", AccessibilityAnalysis);
276+
AddParam(dict, "display_name", DisplayName);
277+
AddParam(dict, "use_filename_as_display_name", UseFilenameAsDisplayName);
278+
AddParam(dict, "asset_folder", AssetFolder);
251279

252280
if (ResourceType == ResourceType.Image)
253281
{

0 commit comments

Comments
 (0)