{"id":29,"date":"2021-01-14T07:41:07","date_gmt":"2021-01-14T07:41:07","guid":{"rendered":"https:\/\/mouryasolutions.in\/blog\/?p=29"},"modified":"2023-01-30T19:50:02","modified_gmt":"2023-01-30T19:50:02","slug":"store-image-on-firebase-storage","status":"publish","type":"post","link":"https:\/\/mouryasolutions.in\/blog\/store-image-on-firebase-storage\/","title":{"rendered":"How to upload images on Firebase Storage"},"content":{"rendered":"<div class=\"post-content\">\r\n<blockquote class=\"wp-block-quote\">\r\n<p>In Firebase, you can store images in the Firebase Storage. Here is an example of how to store an image in Firebase Storage using the Firebase PHP SDK:<\/p>\r\n<\/blockquote>\r\n\r\n\r\n\r\n<h4>First, install the Firebase PHP SDK:<\/h4>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>composer require firebase\/php-jwt\r\ncomposer require kreait\/firebase-php\r\n<\/code><\/pre>\r\n\r\n\r\n\r\n<h4>Next, you can use the following code to store an image in Firebase Storage:<\/h4>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>use Kreait\\Firebase\\Factory;\r\nuse Kreait\\Firebase\\Storage;\r\n\r\n$factory = (new Factory)-&gt;withServiceAccount(__DIR__.'\/service-account.json');\r\n$storage = $factory-&gt;createStorage();\r\n\r\n$image = file_get_contents('image.jpg');\r\n$storage-&gt;put('images\/image.jpg', $image);\r\n<\/code><\/pre>\r\n\r\n\r\n\r\n<p>Note: Replace <code>image.jpg<\/code> with the path to your image file, and replace <code>service-account.json<\/code> with the path to your Firebase Service Account JSON file.<\/p>\r\n<\/div>","protected":false},"excerpt":{"rendered":"<p>In Firebase, you can store images in the Firebase Storage.<a href=\"https:\/\/mouryasolutions.in\/blog\/store-image-on-firebase-storage\/\">Read More<i class=\"fa fa-long-arrow-right\" aria-hidden=\"true\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":512,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/29"}],"collection":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=29"}],"version-history":[{"count":10,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":491,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/29\/revisions\/491"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/media\/512"}],"wp:attachment":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}