Skip to content

Commit

Permalink
Add filename_override upload parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
RTLcoil authored Mar 4, 2021
1 parent 0ed36db commit a8d951f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 18 additions & 0 deletions Shared.IntegrationTests/UploadApi/UploadMethodsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,24 @@ public void TestEvalUploadParameter()
Assert.IsInstanceOf<double>(uploadResult.QualityAnalysis.Focus);
}

[Test, RetryWithDelay]
public void TestUploadFilenameOverride()
{
const string filenameOverride = "test_overridden";

var uploadParams = new ImageUploadParams()
{
File = new FileDescription(m_testImagePath),
Tags = m_apiTag,
FilenameOverride = filenameOverride
};

var uploadResult = m_cloudinary.Upload(uploadParams);

Assert.IsNotNull(uploadResult);
Assert.AreEqual(filenameOverride, uploadResult.OriginalFilename);
}

//[Test, RetryWithDelay]
//public void TestTextAlign()
//{
Expand Down
8 changes: 7 additions & 1 deletion Shared/Actions/AssetsUpload/BasicRawUploadParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public virtual ResourceType ResourceType
get { return Actions.ResourceType.Raw; }
}

/// <summary>
/// Gets or sets file name to override an original file name.
/// </summary>
public string FilenameOverride { get; set; }

/// <summary>
/// Validate object model.
/// </summary>
Expand Down Expand Up @@ -64,10 +69,11 @@ public override void Check()
/// <returns>Sorted dictionary of parameters.</returns>
public override SortedDictionary<string, object> ToParamsDictionary()
{
SortedDictionary<string, object> dict = base.ToParamsDictionary();
var dict = base.ToParamsDictionary();

AddParam(dict, "public_id", PublicId);
AddParam(dict, "type", Type);
AddParam(dict, "filename_override", FilenameOverride);

if (Backup.HasValue)
{
Expand Down

0 comments on commit a8d951f

Please sign in to comment.