@@ -48,6 +48,30 @@ public void testUpload() throws IOException {
4848 String expected_signature = cloudinary .apiSignRequest (to_sign , cloudinary .getStringConfig ("api_secret" ));
4949 assertEquals (result .get ("signature" ), expected_signature );
5050 }
51+
52+ @ Test
53+ public void testUploadUrl () throws IOException {
54+ Map result = cloudinary .uploader ().upload ("http://cloudinary.com/images/logo.png" , Cloudinary .emptyMap ());
55+ assertEquals (result .get ("width" ), 241L );
56+ assertEquals (result .get ("height" ), 51L );
57+ Map <String , Object > to_sign = new HashMap <String , Object >();
58+ to_sign .put ("public_id" , (String ) result .get ("public_id" ));
59+ to_sign .put ("version" , Cloudinary .asString (result .get ("version" )));
60+ String expected_signature = cloudinary .apiSignRequest (to_sign , cloudinary .getStringConfig ("api_secret" ));
61+ assertEquals (result .get ("signature" ), expected_signature );
62+ }
63+
64+ @ Test
65+ public void testUploadDataUri () throws IOException {
66+ Map result = cloudinary .uploader ().upload ("data:image/png;base64,iVBORw0KGgoAA\n AANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0l\n EQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6\n P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC" , Cloudinary .emptyMap ());
67+ assertEquals (result .get ("width" ), 16L );
68+ assertEquals (result .get ("height" ), 16L );
69+ Map <String , Object > to_sign = new HashMap <String , Object >();
70+ to_sign .put ("public_id" , (String ) result .get ("public_id" ));
71+ to_sign .put ("version" , Cloudinary .asString (result .get ("version" )));
72+ String expected_signature = cloudinary .apiSignRequest (to_sign , cloudinary .getStringConfig ("api_secret" ));
73+ assertEquals (result .get ("signature" ), expected_signature );
74+ }
5175
5276 @ Test
5377 public void testRename () throws Exception {
0 commit comments