@@ -690,6 +690,72 @@ imagekitio.delete_custom_metadata_field(
690690)
691691```
692692
693+ ** 28. Response hash**
694+
695+ Each file management function returns a hash with response, error, status, headers, raw_body keys with respective values.
696+
697+ ``` ruby
698+ upload = imagekitio.upload_file(
699+ file: file,
700+ file_name: " default.jpg" ,
701+ folder: ' /test' ,
702+ response_fields: ' tags,customCoordinates,isPrivateFile,metadata' ,
703+ tags: %w[abc def] ,
704+ use_unique_file_name: false ,
705+ is_private_file: true
706+ )
707+ puts upload
708+
709+ ***** Success Output *****
710+
711+ {:headers =>
712+ {" access-control-allow-origin" =>[" *" ],
713+ " x-ik-requestid" =>[" 6963194e-014f-8945-b05a-bdb0e088f1bd" ],
714+ " content-type" =>[" application/json; charset=utf-8" ],
715+ " content-length" =>[" 611" ],
716+ " etag" =>[" W/\" 859-GOeZiRFGOZERjHBgRUhG0EGcODs\" " ],
717+ " date" =>[" Wed, 29 Jun 2022 07:04:33 GMT" ],
718+ " x-request-id" =>[" 6963194e-014f-8945-b05a-bdb0e088f1bd" ],
719+ " connection" =>[" close" ]},
720+ :raw_body =>
721+ " {\" fileId\" :\" 62bjf980rb886bd691b86760\" ,\" name\" :\" default.jpg\" ,\" size\" :102117,\" versionInfo\" :{\" id\" :\" 62bjf980rb886bd691b86760\" ,\" name\" :\" Version 1\" },\" filePath\" :\" /test/default.jpg\" ,\" url\" :\" https://ik.imagekit.io/46865sdf6sdf/test/default.jpg\" ,\" fileType\" :\" image\" ,\" height\" :700,\" width\" :1050,\" thumbnailUrl\" :\" https://ik.imagekit.io/46865sdf6sdf/tr:n-ik_ml_thumbnail/test/default.jpg\" ,\" tags\" :[\" abc\" ,\" def\" ],\" AITags\" :null,\" isPrivateFile\" :true,\" customCoordinates\" :null,\" metadata\" :{\" height\" :700,\" width\" :1050,\" size\" :102117,\" format\" :\" jpg\" ,\" hasColorProfile\" :true,\" quality\" :0,\" density\" :72,\" hasTransparency\" :false,\" exif\" :{},\" pHash\" :\" 90249d9b1fc74367\" }}" ,
722+ :status =>" 200" ,
723+ :response =>
724+ {" fileId" =>" 62bjf980rb886bd691b86760" ,
725+ " name" =>" default.jpg" ,
726+ " size" =>102117 ,
727+ " versionInfo" =>{" id" =>" 62bbf980fb877bd691b86760" , " name" =>" Version 1" },
728+ " filePath" =>" /test/default.jpg" ,
729+ " url" =>" https://ik.imagekit.io/46865sdf6sdf/test/default.jpg" ,
730+ " fileType" =>" image" ,
731+ " height" =>700 ,
732+ " width" =>1050 ,
733+ " thumbnailUrl" =>" https://ik.imagekit.io/46865sdf6sdf/tr:n-ik_ml_thumbnail/test/default.jpg" ,
734+ " tags" =>[" abc" , " def" ],
735+ " AITags" =>nil ,
736+ " isPrivateFile" =>true ,
737+ " customCoordinates" =>nil ,
738+ " metadata" =>{" height" =>700 , " width" =>1050 , " size" =>102117 , " format" =>" jpg" , " hasColorProfile" =>true , " quality" =>0 , " density" =>72 , " hasTransparency" =>false , " exif" =>{}, " pHash" =>" 90249d9b1fc74367" }
739+ }
740+ }
741+
742+
743+ *** Error Output ***
744+
745+ {:headers =>
746+ {" access-control-allow-origin" =>[" *" ],
747+ " x-ik-requestid" =>[" e8j51c37-d859-8794-b7f8-5370r27d96ec" ],
748+ " content-type" =>[" application/json; charset=utf-8" ],
749+ " content-length" =>[" 143" ],
750+ " etag" =>[" W/\" 8f-UcD10NytfppO0fARK0FR+M8L68c\" " ],
751+ " date" =>[" Wed, 29 Jun 2022 07:23:33 GMT" ],
752+ " x-request-id" =>[" e8j51c37-d859-8794-b7f8-5370r27d96ec" ],
753+ " connection" =>[" close" ]},
754+ :raw_body =>
" {\" message\" :\" Your request contains invalid value for customMetadata parameter.\" ,\" help\" :\" For support kindly contact us at [email protected] .\" }" ,
755+ :status =>" 400" ,
756+ :error =>{
" message" =>
" Your request contains invalid value for customMetadata parameter." ,
" help" =>
" For support kindly contact us at [email protected] ." }
757+ }
758+ ```
693759
694760## Utility functions
695761
0 commit comments