File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
test/integration/api/uploader Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -416,6 +416,9 @@ function encode_context(metadataObj) {
416416 return `\"${ escapeMetadataValue ( innerVal ) } \"`
417417 } ) . join ( ',' ) ;
418418 return `${ key } =[${ values } ]`
419+ // if number, convert to string
420+ } else if ( Number . isInteger ( value ) ) {
421+ return `${ key } =${ escapeMetadataValue ( String ( value ) ) } ` ;
419422 // if unknown, return the value as string
420423 } else {
421424 return value . toString ( ) ;
Original file line number Diff line number Diff line change @@ -1274,6 +1274,32 @@ describe("uploader", function () {
12741274 expect ( result . metadata [ METADATA_FIELD_UNIQUE_EXTERNAL_ID ] ) . to . eql ( METADATA_FIELD_VALUE ) ;
12751275 } ) ;
12761276 } ) ;
1277+ it ( 'should allow passing both string and a number for a number smd field' , ( ) => {
1278+ const smdNumberField = 'smd_number_field' ;
1279+ cloudinary . v2 . api . add_metadata_field ( {
1280+ external_id : smdNumberField ,
1281+ label : smdNumberField ,
1282+ type : 'number'
1283+ } ) . then ( ( ) => {
1284+ return Promise . all ( [
1285+ uploadImage ( {
1286+ tags : UPLOAD_TAGS ,
1287+ metadata : {
1288+ [ smdNumberField ] : 123
1289+ }
1290+ } ) ,
1291+ uploadImage ( {
1292+ tags : UPLOAD_TAGS ,
1293+ metadata : {
1294+ [ smdNumberField ] : '123'
1295+ }
1296+ } )
1297+ ] ) ;
1298+ } ) . then ( ( [ firstUpload , secondUpload ] ) => {
1299+ expect ( firstUpload . metadata [ smdNumberField ] ) . to . eql ( 123 ) ;
1300+ expect ( secondUpload . metadata [ smdNumberField ] ) . to . eql ( 123 ) ;
1301+ } ) ;
1302+ } ) ;
12771303 it ( "should be updatable with uploader.update_metadata on an existing resource" , function ( ) {
12781304 let publicId ;
12791305 return uploadImage ( {
You can’t perform that action at this time.
0 commit comments