{"id":3359,"date":"2019-04-03T00:16:05","date_gmt":"2019-04-02T15:16:05","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=3359"},"modified":"2019-04-03T00:16:05","modified_gmt":"2019-04-02T15:16:05","slug":"laravel%e3%81%a7google-cloud-storage%e3%81%b8%e4%bf%9d%e5%ad%98%ef%bc%86%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=3359","title":{"rendered":"Laravel\u3067Google Cloud Storage\u3078\u4fdd\u5b58\uff06\u53d6\u5f97\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u524d\u56de\u306e\u8a18\u4e8b\u300c<a href=\"https:\/\/blog.capilano-fw.com\/?p=3343\">\u5371\u967a\uff01Laravel\u3067\u300cconfig:cache\u300d\u3092\u4f7f\u3046\u6642\u306e\u6ce8\u610f\u70b9<\/a>\u300d\u3067\u306f <code>Google Cloud API<\/code>\u00a0\u306e\u8a71\u984c\u3092\u304a\u5c4a\u3051\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u3053\u306e\u6d41\u308c\u3067\u4eca\u56de\u306f<code>Google Storage<\/code> \u3092Laravel\u3067\u64cd\u4f5c\u3059\u308b\u65b9\u6cd5\u3092\u304a\u5c4a\u3051\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u306e\u3082\u3001\u901a\u5e38\u3067\u3057\u305f\u3089\u30af\u30e9\u30a6\u30c9\u30fb\u30b9\u30c8\u30ec\u30fc\u30b8\u306f\u30a2\u30de\u30be\u30f3\u306e<code>S3<\/code>\u3092\u4f7f\u3046\u306e\u304c\u4e3b\u6d41\u306a\u306e\u304b\u306a\u3068\u3044\u3046\u5370\u8c61\u306a\u3093\u3067\u3059\u3051\u3069\u3001\u5b9f\u306fGoogle API\u3067\u30b5\u30a4\u30ba\u306e\u5927\u304d\u3044\u30d5\u30a1\u30a4\u30eb\u3092\u5229\u7528\u3059\u308b\u5834\u5408\u3001\u4e00\u65e6\u30b9\u30c8\u30ec\u30fc\u30b8\u3078\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u5834\u5408\u304c\u3042\u308b\u306e\u3067\u3001\u304d\u3063\u3068\u9700\u8981\u306f\u3042\u308b\u3093\u3060\u308d\u3046\u3068\u5224\u65ad\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306e\u304a\u984c\u306f\u6b21\u306e\u3068\u304a\u308a\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong style=\"font-size: 25px;\">Laravel \u3067Google Cloud Storage \u3092\u4f7f\u3063\u3066\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\uff06\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\uff01<\/strong><\/p>\n<p>\u305c\u3072\u304a\u697d\u3057\u307f\u304f\u3060\u3055\u3044\ud83d\ude0a\u2728<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2173 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png\" alt=\"\" width=\"300\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24-281x300.png 281w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u5b9f\u884c\u74b0\u5883\uff1a Laravel 5.8, PHP 7.2, nginx 1.14.0<\/p>\n<h1>Google Cloud\u3067\u5fc5\u8981\u306a\u8a2d\u5b9a\u3092\u3059\u308b<\/h1>\n<h2>\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u7528\u610f\u3059\u308b<\/h2>\n<p>\u306a\u306b\u306f\u3068\u3082\u3042\u308cGoogle Cloud\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u306e\u3067\u3001<a href=\"https:\/\/cloud.google.com\/?hl=ja\" target=\"_blank\" rel=\"noopener noreferrer\">Google Cloud<\/a> \u3078\u30a2\u30af\u30bb\u30b9\u3057\uff08\u30a2\u30ab\u30a6\u30f3\u30c8\u304c\u306a\u3051\u308c\u3070\u4f5c\u6210\u3057\u3066\uff09\u30ed\u30b0\u30a4\u30f3\u3092\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u3064\u304f\u308b<\/h2>\n<p>\u30a2\u30ab\u30a6\u30f3\u30c8\u304c\u3067\u304d\u305f\u3089\u3001\u300c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u300d\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u753b\u9762\u5de6\u4e0a\u306b\u3042\u308b\u4ee5\u4e0b\u306e\u90e8\u5206\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u65b0\u3057\u3044\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002\uff08\u3053\u3053\u3067\u306f\u305d\u306e\u307e\u307eDev Test\u3068\u3044\u3046\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f7f\u3044\u307e\u3059\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3368\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_1.png\" alt=\"\" width=\"1048\" height=\"241\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_1.png 1048w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_1-300x69.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_1-768x177.png 768w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_1-1024x235.png 1024w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<h2>\u8a8d\u8a3c\u60c5\u5831\u3092\u8a2d\u5b9a\u3057\u3001\u30ad\u30fc\u306b\u306a\u308b json \u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u6b21\u306b\u8a8d\u8a3c\u60c5\u5831\u3092\u4f5c\u6210\u3057\u307e\u3059\u306e\u3067\u3001\u753b\u9762\u5de6\u4e0a\u306b\u3042\u308b\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u30fb\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30e1\u30cb\u30e5\u30fc\u3092\u8868\u793a\u3057\u3001<strong>\u300cAPI\u3068\u30b5\u30fc\u30d3\u30b9 &gt; \u8a8d\u8a3c\u60c5\u5831\u300d<\/strong>\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3365\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_4.png\" alt=\"\" width=\"428\" height=\"249\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_4.png 428w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_4-300x175.png 300w\" sizes=\"auto, (max-width: 428px) 100vw, 428px\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306a\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u306e\u3067<strong>\u300c\u8a8d\u8a3c\u60c5\u5831\u3092\u4f5c\u6210 &gt; \u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u30ad\u30fc\u300d<\/strong>\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3364\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_5.png\" alt=\"\" width=\"656\" height=\"358\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_5.png 656w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_5-300x164.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/p>\n<p>\u6b21\u306b\u3001\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3068JSON\u3092\u9078\u629e\u3057\u3066\u4f5c\u6210\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3363\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_6.png\" alt=\"\" width=\"488\" height=\"319\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_6.png 488w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_6-300x196.png 300w\" sizes=\"auto, (max-width: 488px) 100vw, 488px\" \/><\/p>\n<p>\u3059\u308b\u3068\u6b21\u306e\u3088\u3046\u306a\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u304c\u51fa\u3066 <code>json<\/code>\u30d5\u30a1\u30a4\u30eb\u304c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u308c\u307e\u3059\u3002<br \/>\n\u3053\u306e <code>json<\/code>\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3063\u3066Google Cloud\u3078\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u306e\u3067\u3001Laravel\u306e<code>storage\/json<\/code>\u306b\u3067\u3082\u8a2d\u7f6e\u3057\u3066\u304a\u304f\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002\uff08\u7ba1\u7406\u3057\u3084\u3059\u3044\u3088\u3046\u306b<code>json<\/code>\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092<code>google_api_key.json<\/code>\u3078\u5909\u66f4\u3057\u3066\u3044\u307e\u3059\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3361\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_8.png\" alt=\"\" width=\"423\" height=\"144\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_8.png 423w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_8-300x102.png 300w\" sizes=\"auto, (max-width: 423px) 100vw, 423px\" \/><\/p>\n<h2>Google Storage\u306b\u30d0\u30b1\u30c3\u30c8\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u7d9a\u3044\u3066\u3001Storage\u306e\u8a2d\u5b9a\u3067\u3059\u3002<br \/>\n\u5148\u307b\u3069\u3068\u540c\u3058\u304f\u30da\u30fc\u30b8\u5de6\u4e0a\u306e\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u30fb\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30e1\u30cb\u30e5\u30fc\u3092\u8868\u793a\u3057\u3001\u300cStorage\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3367\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_2.png\" alt=\"\" width=\"435\" height=\"685\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_2.png 435w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_2-191x300.png 191w\" sizes=\"auto, (max-width: 435px) 100vw, 435px\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u306e\u3067\u300c\u30d0\u30b1\u30c3\u30c8\u3092\u4f5c\u6210\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3366\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_3.png\" alt=\"\" width=\"429\" height=\"233\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_3.png 429w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_3-300x163.png 300w\" sizes=\"auto, (max-width: 429px) 100vw, 429px\" \/><\/p>\n<p>\u305d\u3057\u3066\u3001\u6b21\u306e\u753b\u9762\u3067\u30d0\u30b1\u30c3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u203b \u540d\u524d\u306f\u4ed6\u306e\u4eba\u304c\u4f7f\u3063\u3066\u3044\u306a\u3044\u3082\u306e\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u307e\u305f\u3001\u4eca\u56de\u306f\u56fd\u5185\u3060\u3051\u3067\u306e\u904b\u7528\u3092\u60f3\u5b9a\u3057\u3066\u3044\u308b\u306e\u3067\u300cRegional + Tokyo\u300d\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u3053\u306f\u304a\u597d\u307f\u3067\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3360\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_9.png\" alt=\"\" width=\"492\" height=\"551\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_9.png 492w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_9-268x300.png 268w\" sizes=\"auto, (max-width: 492px) 100vw, 492px\" \/><\/p>\n<p>\u5165\u529b\uff06\u9078\u629e\u304c\u7d42\u308f\u3063\u305f\u3089\u4f5c\u6210\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308c\u3070\u5b8c\u4e86\u3067\u3059\uff01<\/p>\n<h3>\u30d0\u30b1\u30c3\u30c8\u3068\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u3064\u3044\u3066<\/h3>\n<p>Google Cloud\u3067\u306f\u300c\u30d0\u30b1\u30c3\u30c8\u300d\u3068\u300c\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u300d\u3068\u3044\u3046\u540d\u524d\u304c\u51fa\u3066\u304d\u307e\u3059\u304c\u3001\u3053\u308c\u306f\u30d1\u30bd\u30b3\u30f3\u3067\u3044\u3046\u300c\u30d5\u30a9\u30eb\u30c0\u300d\u3068\u300c\u30d5\u30a1\u30a4\u30eb\u300d\u3068\u540c\u3058\u3088\u3046\u306a\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u30d0\u30b1\u30c3\u30c8\u306e\u4e2d\u306b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u305f\u304f\u3055\u3093\u5165\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<p>\u2193\u2193\u2193\u3053\u3093\u306a\u30a4\u30e1\u30fc\u30b8\u3002\u3053\u308c\u304b\u3089\u300c\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u300d\u3092Larael\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u3044\u304d\u307e\u3059\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3370\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/office-3360775_640_2.png\" alt=\"\" width=\"640\" height=\"426\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/office-3360775_640_2.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/office-3360775_640_2-300x200.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<h1>Laravel\u304b\u3089Google Storage\u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b<\/h1>\n<h2>\u6e96\u5099<\/h2>\n<h3>\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u3044\u304f\u524d\u306b<code>Google Storage<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092<code>composer<\/code>\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>composer require google\/cloud-storage<\/strong><\/pre>\n<h3>.env \u3078\u8a8d\u8a3c\u60c5\u5831\u3092\u66f8\u304d\u8fbc\u3080<\/h3>\n<p>\u6b21\u306b\u3001Google Cloud\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305fjson\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u3092<code>GOOGLE_APPLICATION_CREDENTIALS<\/code>\u3068\u3057\u3066<code>.env<\/code>\u306b\u767b\u9332\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>GOOGLE_APPLICATION_CREDENTIALS=\/home\/sukohi\/xxxxxxxx\/laravel58\/storage\/json\/google_api_key.json<\/strong><\/pre>\n<p>\u203b \u6ce8\u610f\u70b9\uff1a<a href=\"https:\/\/blog.capilano-fw.com\/?p=3343\">\u524d\u56de\u8a18\u4e8b<\/a>\u3067\u66f8\u3044\u305f\u3088\u3046\u306b<code>php artisan config:cache<\/code>\u3092\u3057\u3066\u3057\u307e\u3046\u3068env()\u304c\u52b9\u304b\u306a\u304f\u306a\u308b\u305f\u3081\u3046\u307e\u304f\u3044\u304b\u306a\u304f\u306a\u308a\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001<code>php artisan config:clear<\/code>\u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u524a\u9664\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3>\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f<\/h3>\n<p>\u4eca\u56de\u306f<code>storage\/text\/test.txt<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<h2>\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9<\/h2>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u30b3\u30fc\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>use Google\\Cloud\\Storage\\StorageClient;<\/strong>\r\n\r\n<strong>$client = new StorageClient();<\/strong>\r\n<strong>$bucket = $client-&gt;bucket('xxxxxxxxxx'); \/\/ \u4f5c\u6210\u3057\u305f\u30d0\u30b1\u30c3\u30c8\u540d<\/strong>\r\n<strong>$bucket-&gt;upload(<\/strong>\r\n<strong>    fopen(storage_path('text\/test.txt'), 'r')<\/strong>\r\n<strong>);<\/strong><\/pre>\n<p>\u3084\u3063\u3066\u3044\u308b\u3053\u3068\u306f\u3001\u307e\u305a<code>StorageClient<\/code>\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3057\u3001\u305d\u3053\u304b\u3089\u30d0\u30b1\u30c3\u30c8\u540d\uff08\u5148\u307b\u3069\u4f5c\u6210\u3057\u305f\u3082\u306e\u3067\u3059\uff09\u3092\u6307\u5b9a\u3057\u3066\u30d0\u30b1\u30c3\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3002\u305d\u3057\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u3066\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3068\u3044\u3046\u6d41\u308c\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u3066\u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3373\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_14.png\" alt=\"\" width=\"1077\" height=\"365\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_14.png 1077w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_14-300x102.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_14-768x260.png 768w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_14-1024x347.png 1024w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>\u306f\u3044\uff01<br \/>\n\u3046\u307e\u304f<code>test.txt<\/code> \u304c\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u307e\u3057\u305f\ud83d\ude0a\u2728<\/p>\n<h2>\u30d5\u30a1\u30a4\u30eb\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h2>\n<p>\u3067\u306f\u3001\u5148\u307b\u3069\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u305f<code>test.txt<\/code>\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3001\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u306b<code>test_from_gs.txt<\/code>\u3068\u3044\u3046\u540d\u524d\u3067\u4fdd\u5b58\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>$client = new StorageClient();<\/strong>\r\n<strong>$bucket = $client-&gt;bucket('xxxxxxxxxx'); \/\/ \u4f5c\u6210\u3057\u305f\u30d0\u30b1\u30c3\u30c8\u540d<\/strong>\r\n<strong>$object = $bucket-&gt;object('test.txt');   \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a<\/strong>\r\n<strong>$object-&gt;downloadToFile(storage_path('text\/test_from_gs.txt'));<\/strong><\/pre>\n<p>\u3084\u308a\u65b9\u306f\u3001\u5148\u307b\u3069\u3068\u540c\u3058\u304f\u30d0\u30b1\u30c3\u30c8\u3092\u53d6\u5f97\u3057\u3066\u3001\u3055\u3089\u306b\u305d\u3053\u304b\u3089\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u305d\u3057\u3066\u3001<code>downloadToFIle()<\/code>\u3067\u5185\u5bb9\u3092\u4fdd\u5b58\u3059\u308c\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u304c\u5b8c\u4e86\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3374\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_15.png\" alt=\"\" width=\"427\" height=\"151\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_15.png 427w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_15-300x106.png 300w\" sizes=\"auto, (max-width: 427px) 100vw, 427px\" \/><\/p>\n<h3>\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3059\u308b<\/h3>\n<p>\u3067\u306f\u3001\u6700\u5f8c\u306b\u30d5\u30a1\u30a4\u30eb\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff09\u306e\u524a\u9664\u3067\u3059\u3002<\/p>\n<pre><strong>$client = new StorageClient();<\/strong>\r\n<strong>$bucket = $client-&gt;bucket('xxxxxxxxxx'); \/\/ \u4f5c\u6210\u3057\u305f\u30d0\u30b1\u30c3\u30c8\u540d<\/strong>\r\n<strong>$object = $bucket-&gt;object('test.txt');   \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a<\/strong>\r\n<strong>$object-&gt;delete();<\/strong><\/pre>\n<p>\u3068\u3044\u3063\u3066\u3082\u3053\u308c\u3082\u7c21\u5358\u3067\u3001\u30d0\u30b1\u30c3\u30c8\u304b\u3089\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3057\u3066<code>delete()<\/code>\u3092\u5b9f\u884c\u3059\u308b\u305f\u3051\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001<strong>\u6ce8\u610f\u304c\u5fc5\u8981\u306a\u306e\u304c\u8fd4\u308a\u5024\uff08return\uff09\u304c\u5b58\u5728\u3057\u306a\u3044\uff08google\/cloud-storage version 1.11 \u73fe\u5728\uff09\u3053\u3068<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u524a\u9664\u304c\u6210\u529f\u3057\u305f\u304b\u3069\u3046\u304b\u3092\u77e5\u308b\u305f\u3081\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u00a0<code>try \u301c catch<\/code> \u3092\u4f7f\u3046\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>try {<\/strong>\r\n\r\n    \/\/ \u7701\u7565\r\n    $object-&gt;delete();\r\n\r\n<strong>} catch (\\Exception $e) {<\/strong>\r\n\r\n    \/\/ \u524a\u9664\u5931\u6557\r\n\r\n<strong>}<\/strong><\/pre>\n<h1>\u3061\u306a\u307f\u306b<\/h1>\n<p>\u3082\u3057Google API\u306e\u8a8d\u8a3c\u304c\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u5834\u5408\u306f\u3001\u6a29\u9650\u304c\u304d\u3061\u3093\u3068\u8a2d\u5b9a\u3067\u304d\u3066\u3044\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308b\u306e\u3067\u3001\u6b21\u306e\u624b\u9806\u3092\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305a\u3001\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u30fb\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30e1\u30cb\u30e5\u30fc\u3092\u8868\u793a\u3057\u3001\u300cIAM\u3068\u7ba1\u7406 &gt; IAM\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3381\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_17.png\" alt=\"\" width=\"479\" height=\"433\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_17.png 479w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_17-300x271.png 300w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001IAM\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u30da\u30fc\u30b8\u4e0a\u90e8\u306b\u3042\u308b\u300c\u8ffd\u52a0\u300d\u3068\u3044\u3046\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3382\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_16.png\" alt=\"\" width=\"283\" height=\"45\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001\u30e1\u30f3\u30d0\u30fc\u8ffd\u52a0\u306e\u30d5\u30a9\u30fc\u30e0\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u300c\u65b0\u3057\u3044\u30e1\u30f3\u30d0\u30fc\u300d\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f json\u5185\u306e<code>client_email<\/code>\u306b\u304b\u304b\u308c\u3066\u3044\u308b\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9<strong>\uff08\u4f8b\uff1axxxxxxxx@xxxxxxx.iam.gserviceaccount.com\uff09<\/strong>\u3092\u5165\u529b\u3057\u3001\u5f79\u5272\u3092\u300c\u30b9\u30c8\u30ec\u30fc\u30b8\u7ba1\u7406\u8005\u300d\u3068\u3057\u3066\u4fdd\u5b58\u3092\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3384\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_13.png\" alt=\"\" width=\"552\" height=\"437\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_13.png 552w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_13-300x238.png 300w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3383\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_10.png\" alt=\"\" width=\"694\" height=\"415\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_10.png 694w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/google_storage_10-300x179.png 300w\" sizes=\"auto, (max-width: 694px) 100vw, 694px\" \/><\/p>\n<p>\u3053\u308c\u3067\u6a29\u9650\u306e\u8a2d\u5b9a\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u4eca\u56de\u306f<code>Google Storage<\/code>\u3092<code>Laravel<\/code>\u3067\u64cd\u4f5c\u3059\u308b\u65b9\u6cd5\u3092\u304a\u5c4a\u3051\u3057\u307e\u3057\u305f\u3002\u305c\u3072\u304a\u5f79\u306b\u305f\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2594 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/23.png\" alt=\"\" width=\"182\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/23.png 182w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/23-171x300.png 171w\" sizes=\"auto, (max-width: 182px) 100vw, 182px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u524d\u56de\u306e\u8a18\u4e8b\u300c\u5371\u967a\uff01Laravel\u3067\u300cconfig:cache\u300d\u3092\u4f7f\u3046\u6642\u306e\u6ce8\u610f\u70b9\u300d\u3067\u306f Google Cloud API\u00a0\u306e\u8a71\u984c\u3092\u304a\u5c4a\u3051\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u3053 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=3359\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel\u3067Google Cloud Storage\u3078\u4fdd\u5b58\uff06\u53d6\u5f97\u3059\u308b\u65b9\u6cd5&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":3379,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,17],"tags":[134,29,135],"class_list":["post-3359","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-17","tag-api","tag-google","tag-135"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/3359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3359"}],"version-history":[{"count":7,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/3359\/revisions"}],"predecessor-version":[{"id":3385,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/3359\/revisions\/3385"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/3379"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}