{"id":613,"date":"2021-09-14T18:00:00","date_gmt":"2021-09-14T09:00:00","guid":{"rendered":"https:\/\/www.sea2800.com\/?p=613"},"modified":"2022-08-03T10:38:27","modified_gmt":"2022-08-03T01:38:27","slug":"django%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%83%96%e3%83%a9%e3%82%a6%e3%82%b6%e3%81%8b%e3%82%89aws-s%ef%bc%93%e3%81%ab%e7%9b%b4%e6%8e%a5%e3%82%a2%e3%83%83%e3%83%97%e3%83%ad%e3%83%bc%e3%83%89%e3%81%99","status":"publish","type":"post","link":"https:\/\/www.sea2800.com\/?p=613","title":{"rendered":"Django\u3092\u4f7f\u3063\u3066\u30d6\u30e9\u30a6\u30b6\u304b\u3089AWS S\uff13\u306b\u76f4\u63a5\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b"},"content":{"rendered":"\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<!-- test -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-7910153846163820\" data-ad-slot=\"9115942114\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>Google\u306eGAE\uff08Google App Engin) \u3084AWS\u306eElastic Beanstalk\u306a\u3069\u306ePaaS(Platform as a Service)\u306e\u4e2d\u306b\u306f\u3001\u4e00\u56de\u306e\u901a\u4fe1\u306b\u5236\u9650\u304c\u3064\u3044\u3066\u3044\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u52d5\u753b\u30d5\u30a1\u30a4\u30eb\u306a\u3069\u306e\u5927\u304d\u306a\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3068Error413(\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u304c\u5927\u304d\u3059\u304e\u3066\u767a\u751f\u3059\u308b\u30a8\u30e9\u30fc\uff09\u304c\u8d77\u304d\u307e\u3059\u3002\u81ea\u5206\u306e\u30b5\u30a4\u30c8\u3067\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u52d5\u753b\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u3057\u305f\u3044\u3068\u304d\u306b\u306f\u3001S\uff13\u306a\u3069\u306e\u30af\u30e9\u30a6\u30c9\u30b9\u30c8\u30ec\u30fc\u30b8\u306b\u4e00\u5b9a\u6642\u9593\u6709\u52b9\u306aURL\u3092\u4f7f\u3063\u3066\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u76f4\u63a5\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3084stack overflow\u306a\u3069\u306e\u8cea\u554f\u30b5\u30a4\u30c8\u3092\u8997\u3044\u3066\u3082\u7f72\u540d\u4ed8\u304dURL\u307e\u3067\u306e\u4f5c\u6210\u306b\u3064\u3044\u3066\u306f\u66f8\u304b\u308c\u3066\u3044\u3066\u3082\u3001\u305d\u308c\u3092\u4f7f\u3063\u3066\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u76f4\u63a5\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u65b9\u6cd5\u307e\u3067\u306f\u66f8\u304b\u308c\u3066\u3044\u306a\u3044\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002\u305d\u3053\u3067\u6642\u9593\u3092\u304b\u3051\u3066\u3084\u3063\u3068\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305f\u306e\u3067\u3082\u3046\u4e8c\u5ea6\u3068\u5fd8\u308c\u306a\u3044\u3088\u3046\u306b\u30e1\u30e2\u3068\u3057\u3066\u6b8b\u3057\u307e\u3059\u3002\uff08 \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u3069\u3046\u3084\u3063\u3066django\u30e2\u30c7\u30eb\u306b\u3064\u306a\u3052\u3066\u30d6\u30e9\u30a6\u30b6\u3067\u95b2\u89a7\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u304b\u306f\u8003\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3060\u3051\u3067\u304d\u305f\u306e\u3067\uff09<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69fb3d5fd52a0\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69fb3d5fd52a0\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.sea2800.com\/?p=613\/#%E5%89%8D%E6%8F%90\" >\u524d\u63d0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.sea2800.com\/?p=613\/#%E7%9C%81%E7%95%A5%E4%BA%8B%E9%A0%85\" >\u7701\u7565\u4e8b\u9805<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.sea2800.com\/?p=613\/#AWS_S3%E3%81%AE%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E8%A8%B1%E5%8F%AF%E3%82%92%E8%A8%AD%E5%AE%9A%E3%81%99%E3%82%8B%E3%80%82\" >AWS S3\u306e\u30a2\u30af\u30bb\u30b9\u8a31\u53ef\u3092\u8a2d\u5b9a\u3059\u308b\u3002<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.sea2800.com\/?p=613\/#Django%E3%81%AE%E8%A8%AD%E5%AE%9A\" >Django\u306e\u8a2d\u5b9a<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.sea2800.com\/?p=613\/#%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E4%BD%9C%E3%82%8B\" >\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.sea2800.com\/?p=613\/#Storage_%E3%81%A8Rest-frame-work%E3%82%92settingspy%E3%81%AB%E8%AA%8D%E7%9F%A5%E3%81%95%E3%81%9B%E3%82%8B\" >Storage \u3068Rest-frame-work\u3092settings.py\u306b\u8a8d\u77e5\u3055\u305b\u308b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.sea2800.com\/?p=613\/#django-StoragesAWS%E3%81%AE%E8%A8%AD%E5%AE%9A\" >django-Storages(AWS)\u306e\u8a2d\u5b9a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.sea2800.com\/?p=613\/#Model%E3%81%AE%E4%BD%9C%E6%88%90\" >Model\u306e\u4f5c\u6210<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.sea2800.com\/?p=613\/#Viewspy%E3%81%AE%E8%A8%AD%E5%AE%9A\" >Views.py\u306e\u8a2d\u5b9a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.sea2800.com\/?p=613\/#URLpy%E3%81%AE%E8%A8%AD%E5%AE%9A\" >URL.py\u306e\u8a2d\u5b9a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.sea2800.com\/?p=613\/#javascript%E3%81%A8html%E3%81%AE%E8%A8%AD%E5%AE%9A\" >javascript\u3068html\u306e\u8a2d\u5b9a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.sea2800.com\/?p=613\/#%E3%82%A2%E3%83%83%E3%83%97%E3%83%AD%E3%83%BC%E3%83%89%E3%83%9A%E3%83%BC%E3%82%B8%E3%81%AE%E4%BD%9C%E6%88%90\" >\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30da\u30fc\u30b8\u306e\u4f5c\u6210<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%89%8D%E6%8F%90\"><\/span>\u524d\u63d0<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u4eca\u56de<a href=\"https:\/\/www.codingforentrepreneurs.com\/blog\/large-file-uploads-with-amazon-s3-django\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u3053\u3061\u3089\u306e\u30b5\u30a4\u30c8<\/a>\u3092\u53c2\u8003\u306b\u5b9f\u88c5\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u4f5c\u6210\u6642\u671f\u304c\u5c11\u3057\u53e4\u3044\u306e\u3067\u3001\u305d\u306e\u901a\u308a\u306b\u3084\u3063\u3066\u3044\u308b\u3068\u5f15\u3063\u304b\u304b\u308b\u90e8\u5206\u304c\u304b\u306a\u308a\u3042\u3063\u305f\u306e\u3067\u81ea\u5206\u304c\u5909\u66f4\u3057\u305f\u7b87\u6240\u3092\u542b\u3081\u3066\u8a18\u9332\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306e\u4f7f\u7528\u3057\u305f\u3082\u306e\u306f\u6b21\u306e\u901a\u308a\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Django-3.1<\/li><li>AWS S\uff13<\/li><li>Django-rest_framework<\/li><li>Javascript<\/li><\/ul>\n\n\n\n<p>\u3092\u4f7f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%9C%81%E7%95%A5%E4%BA%8B%E9%A0%85\"><\/span>\u7701\u7565\u4e8b\u9805<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u4eca\u56de\u306fdjango\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210\u65b9\u6cd5\u3068\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4f5c\u6210\u65b9\u6cd5\u30ab\u30c3\u30c8\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>AWS\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u4f5c\u6210\u3082\u307e\u305f\u540c\u69d8\u306b\u30ab\u30c3\u30c8\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>boostarp<\/p>\n\n\n\n<p>\u30a2\u30ab\u30a6\u30f3\u30c8\u30e6\u30fc\u30b6\u30fc\u306e\u4f5c\u6210<\/p>\n\n\n\n<p>\u4f5c\u6210\u65b9\u6cd5\u3092\u78ba\u8a8d\u3057\u305f\u3044\u65b9\u306f\u3001\u3053\u3061\u3089\u306e\u30da\u30fc\u30b8\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-espresso-log wp-block-embed-espresso-log\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"SlNPEokPKS\"><a href=\"https:\/\/www.sea2800.com\/?p=532\">\u697d\u3057\u3066Django\u30a2\u30d7\u30ea\u3092\u4f5c\u308bPART\uff11<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;\u697d\u3057\u3066Django\u30a2\u30d7\u30ea\u3092\u4f5c\u308bPART\uff11&#8221; &#8212; \u30c8\u30e9\u30f3\u306e\u8a18\u9332\" src=\"https:\/\/www.sea2800.com\/?p=532&#038;embed=true#?secret=53p8Tm9Q4d#?secret=SlNPEokPKS\" data-secret=\"SlNPEokPKS\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-espresso-log wp-block-embed-espresso-log\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"UDGsUJEZlx\"><a href=\"https:\/\/www.sea2800.com\/?p=596\">Django-storage\u3067s\uff13v\uff14\u3092\u4f7f\u3046\u3068css\u304c\u8868\u793a\u3055\u308c\u306a\u3044\u6642\u306e\u89e3\u6c7a\u65b9\u6cd5<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Django-storage\u3067s\uff13v\uff14\u3092\u4f7f\u3046\u3068css\u304c\u8868\u793a\u3055\u308c\u306a\u3044\u6642\u306e\u89e3\u6c7a\u65b9\u6cd5&#8221; &#8212; \u30c8\u30e9\u30f3\u306e\u8a18\u9332\" src=\"https:\/\/www.sea2800.com\/?p=596&#038;embed=true#?secret=XcmDaUCbFl#?secret=UDGsUJEZlx\" data-secret=\"UDGsUJEZlx\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<!-- test -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-7910153846163820\" data-ad-slot=\"9115942114\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"AWS_S3%E3%81%AE%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E8%A8%B1%E5%8F%AF%E3%82%92%E8%A8%AD%E5%AE%9A%E3%81%99%E3%82%8B%E3%80%82\"><\/span>AWS S3\u306e\u30a2\u30af\u30bb\u30b9\u8a31\u53ef\u3092\u8a2d\u5b9a\u3059\u308b\u3002<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>AWS\u3067\u30d0\u30b1\u30c3\u30c8\u3092\u4f5c\u6210\u5f8c\u540d\u524d\u306e\u9805\u76ee\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3089\u8868\u793a\u3055\u308c\u308bpermmissions\u3092\u9078\u629e\u3057\u305f\u3089\u305d\u306e\u4e0b\u306e\u65b9\u306bCross-origin resource sharing (CORS)\u3068\u3044\u3046\u9805\u76ee\u304c\u3042\u308a\u307e\u3059\u3002JSON\u5f62\u5f0f\u3067\u4e0b\u8a18\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;\n    {\n        \"AllowedHeaders\": &#91;\n            \"*\"\n        ],\n        \"AllowedMethods\": &#91;\n            \"HEAD\",\n            \"GET\",\n            \"PUT\",\n            \"POST\",\n            \"DELETE\"\n        ],\n        \"AllowedOrigins\": &#91;\n            \"*\"\n        ],\n        \"ExposeHeaders\": &#91;]\n    }\n]<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u3092\u6307\u793a\u3059\u308b\u3053\u3068\u3067\u81ea\u5206\u3067\u8a2d\u5b9a\u3057\u305f\u30c9\u30e1\u30a4\u30f3\u304b\u3089\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30d0\u30b1\u30c3\u30c8\u306b\u76f4\u63a5\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u3092\u8a31\u53ef\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3057\u304b\u3057\u305d\u308c\u3060\u3051\u3067\u306f\u8a31\u53ef\u304c\u8db3\u308a\u305a\u3001\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u306a\u3044\u306e\u3067S\uff13\u3067\u767b\u9332\u3057\u3066\u3042\u308b\u30b0\u30eb\u30fc\u30d7\u306b\u6a29\u9650\u3092\u6301\u305f\u305b\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>IAM\u3092\u958b\u304dUserGroups\u3092\u958b\u304d\u3001\u81ea\u5206\u306e\u30b0\u30eb\u30fc\u30d7\u3092\u9078\u629e\u3001permisson\u3092\u958b\u304dcreate policy\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p> \u30dd\u30ea\u30b7\u30fc\u4f5c\u6210\u753b\u9762\u3067Json\u5f62\u5f0f\u306b\u3057\u3066\u304b\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": &#91;\n        {\n            \"Sid\": \"VisualEditor0\",\n            \"Effect\": \"Allow\",\n            \"Action\": &#91;\n                \"s3:ListBucketMultipartUploads\",\n                \"s3:ListBucketVersions\",\n                \"s3:ListBucket\",\n                \"s3:GetBucketLocation\"\n            ],\n            \"Resource\": \"arn:aws:s3:::&lt;your-bucket_name&gt;\"\n        },\n        {\n            \"Sid\": \"VisualEditor1\",\n            \"Effect\": \"Allow\",\n            \"Action\": &#91;\n                \"s3:AbortMultipartUpload\",\n                \"s3:ListMultipartUploadParts\"\n            ],\n            \"Resource\": \"arn:aws:s3:::&lt;your-bucket_name&gt;\/*\"\n        },\n        {\n            \"Sid\": \"VisualEditor2\",\n            \"Effect\": \"Allow\",\n            \"Action\": &#91;\n                \"s3:ListAccessPointsForObjectLambda\",\n                \"s3:ListAllMyBuckets\"\n            ],\n            \"Resource\": \"*\"\n        },\n        {\n            \"Sid\": \"VisualEditor3\",\n            \"Effect\": \"Allow\",\n            \"Action\": \"s3:*Object*\",\n            \"Resource\": &#91;\n                \"arn:aws:s3:::&lt;your-bucket_name&gt;\",\n                \"arn:aws:s3:::&lt;your-bucket_name&gt;*\",\n                \"arn:aws:s3-object-lambda:&lt;your-_region_name&gt;:&lt;acsesspoint_id&gt;:accesspoint\/*\"\n            ]\n        }\n    ]\n}<\/code><\/pre>\n\n\n\n<p>Policy\u3092\u4f5c\u6210\u5f8c\u30b0\u30eb\u30fc\u30d7\u306b\u3053\u306e\u8a31\u53ef\u3092\u8a8d\u53ef\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3084\u308a\u65b9\u3068\u3057\u3066\u306f\u3001\u30b0\u30eb\u30fc\u30d7\u306bS\uff13\u306e\u6a29\u9650\u3092\u4ed8\u4e0e\u3059\u308b\u306e\u3068\u540c\u3058\u3067\u3057<\/p>\n\n\n\n<p>\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u30d6\u30e9\u30a6\u30b6\u304b\u3089S\uff13\u306b\u76f4\u63a5\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u4e0b\u6e96\u5099\u306f\u6574\u3044\u307e\u3057\u305f\u3002\u6b21\u306bdjango\u306e\u65b9\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3067\u304d\u308b\u30b5\u30a4\u30c8\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Django%E3%81%AE%E8%A8%AD%E5%AE%9A\"><\/span>Django\u306e\u8a2d\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>django\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u3057\u305f\u3089django-storages\u3068django rest framework\u3000\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u884c\u3044\u307e\u3059<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install django-storages\n\npip install djangorestframework\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E4%BD%9C%E3%82%8B\"><\/span>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>python manage.py startapp upload<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Storage_%E3%81%A8Rest-frame-work%E3%82%92settingspy%E3%81%AB%E8%AA%8D%E7%9F%A5%E3%81%95%E3%81%9B%E3%82%8B\"><\/span>Storage \u3068Rest-frame-work\u3092settings.py\u306b\u8a8d\u77e5\u3055\u305b\u308b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>settings.py \u3092\u958b\u3044\u3066\u3001INSTALLED_APPS\u304c\u66f8\u3044\u3066\u3042\u308b[]\u5185\u306b\u4f5c\u3063\u305f\u30a2\u30d7\u30ea\u540d\u3068&#8221;storage&#8221;\u3001&#8221;rest_framework&#8221;\u3068\u66f8\u304d\u8fbc\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSTALLED_APPS = &#91;\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'bootstrap4',\n    'django.forms',\n    'rest_framework', # \u8ffd\u52a0\n    'django_cleanup.apps.CleanupConfig',\n    'storages',#\u8ffd\u52a0\n    'django_grpc_framework',\n    'video'\n\n    \n\n]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"django-StoragesAWS%E3%81%AE%E8%A8%AD%E5%AE%9A\"><\/span>django-Storages(AWS)\u306e\u8a2d\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>settings.py\u306e\u307e\u307e\u3001Storage\u306e\u30a2\u30af\u30bb\u30b9\u7b49\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>AWS_ACCESS_KEY_ID = 'AWS_UPLOAD_ACCESS_KEY_ID'  \nAWS_SECRET_ACCESS_KEY =env('AWS_SECRET_KEY')\nAWS_STORAGE_BUCKET_NAME = 'your_bucket_name'\nAWS_LOCATION = 'static'\nAWS_S3_SIGNATURE_VERSION = 's3v4'\nAWS_S3_REGION_NAME = 'ap-northeast-1'\nAWS_DEFAULT_ACL = None<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u3067storage\u306e\u8a2d\u5b9a\u306f\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002\u6b21\u306f\u30e2\u30c7\u30eb\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Model%E3%81%AE%E4%BD%9C%E6%88%90\"><\/span>Model\u306e\u4f5c\u6210<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u6b21\u306b\u5927\u304d\u306a\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306b\u540d\u524d\u3084\u3089\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u305f\u65e5\u3092\u8a18\u5165\u3057\u305f\u308a\u3059\u308b\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4eca\u56de\u306f\u30d3\u30c7\u30aa\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Video(models.Model):\n    user = models.ForeignKey( settings.AUTH_USER_MODEL,on_delete=models.CASCADE)\n    video = models.FileField(upload_to='media\/user\/video',verbose_name='upload to moive ',\n    help_text=\"test\",)\n    title = models.CharField(_('\u30bf\u30a4\u30c8\u30eb'),max_length=50,blank=True)\n    text = models.TextField(verbose_name='text',blank=True,)\n    create_at = models.DateTimeField('CreateDay',null=True,default=timezone.now)\n\n    def __str__(self):\n        return self.title\n    <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Viewspy%E3%81%AE%E8%A8%AD%E5%AE%9A\"><\/span>Views.py\u306e\u8a2d\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3067\u304d\u308b\u69d8\u306b\u3044\u308d\u3044\u308d\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import base64\nimport hashlib\nimport hmac\nimport os\nimport time\nfrom rest_framework import permissions, status, authentication\nfrom rest_framework.response import Response\nfrom rest_framework.views import APIView\nfrom django.conf import settings\n\nfrom .models import Video\n\nclass FilePolicy(APIView):\n    \"\"\"\n    This view is to get the AWS Upload Policy for our s3 bucket.\n    What we do here is first create a FileItem object instance in our\n    Django backend. This is to include the FileItem instance in the path\n    we will use within our bucket as you'll see below.\n    \"\"\"\n    permission_classes = &#91;permissions.IsAuthenticated]\n    authentication_classes = &#91;authentication.SessionAuthentication]\n\n    def post(self, request, *args, **kwargs):\n        \"\"\"\n        The initial post request includes the filename\n        and auth credientails. In our case, we'll use\n        Session Authentication but any auth should work.\n        \"\"\"\n        filename_req = request.data.get('filename')\n        if not filename_req:\n                return Response({\"message\": \"A filename is required\"}, status=status.HTTP_400_BAD_REQUEST)\n        policy_expires = int(time.time()+5000)\n        user = request.user\n        username_str = str(request.user.username)\n\n        video_type = os.path.splitext(filename_req)\n        video_str = str(filename_req)\n        \"\"\"\n        Below we create the Django object. We'll use this\n        in our upload path to AWS. \n\n        Example:\n        To-be-uploaded file's name: Some Random File.mp4\n        Eventual Path on S3: &lt;bucket&gt;\/username\/2312\/2312.mp4\n        \"\"\"\n        file_obj = Video.objects.create(user=user, title=filename_req,)\n        file_obj_id = file_obj.id\n\n        upload_start_path = \"media\/media\/user\/video\/\".format(\n                    username = username_str,\n                    file_obj_id=file_obj_id,\n                    video_str=video_str\n            )\n        _, file_extension = os.path.splitext(filename_req)\n        filename_final = \"{file_obj_id}\".format(\n                    file_obj_id= video_str,\n                    file_extension=file_extension\n\n                )\n        \"\"\"\n        Eventual file_upload_path includes the renamed file to the \n        Django-stored FileItem instance ID. Renaming the file is \n        done to prevent issues with user generated formatted names.\n        \"\"\"\n        final_upload_path = \"{upload_start_path}{filename_final}\".format(\n                                 upload_start_path=video_str,\n                                 filename_final=filename_final,\n                            )\n        video =   'media\/user\/video\/{filename_final}'.format(\n                        bucket=settings.AWS_STORAGE_BUCKET_NAME,  \n                        region=settings.AWS_UPLOAD_REGION,\n                        user = username_str,\n                        filename_final=filename_final,\n                        video_str=video_str\n                        \n        )       \n        file_obj.video = video\n        if filename_req and file_extension:\n            \"\"\"\n            Save the eventual path to the Django-stored FileItem instance\n            \"\"\"\n            file_obj.path = final_upload_path\n            file_obj.save()\n\n        policy_document_context = {\n            \"expire\": policy_expires,\n            \"bucket_name\":settings.AWS_STORAGE_BUCKET_NAME,\n            \"key_name\": \"\",\n            \"acl_name\": \"private\",\n            \"content_name\": \"\",\n            \"content_length\": 42880000,\u6700\u5927\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u5bb9\u91cf\n            \"upload_start_path\": upload_start_path,\n\n            }\n        policy_document = \"\"\"\n        {\"expiration\": \"2026-01-01T00:00:00Z\",\n          \"conditions\": &#91; \n            {\"bucket\": \"%(bucket_name)s\"}, \n            &#91;\"starts-with\", \"$key\", \"%(upload_start_path)s\"],\n            {\"acl\": \"%(acl_name)s\"},\n            \n            &#91;\"starts-with\", \"$Content-Type\", \"%(content_name)s\"],\n            &#91;\"starts-with\", \"$filename\", \"\"],\n            &#91;\"content-length-range\", 0, %(content_length)d]\n          ]\n        }\n        \"\"\" % policy_document_context\n        aws_secret = str.encode(AWS_SECRET_ACCESS_KEY)\n        policy_document_str_encoded = str.encode(policy_document.replace(\" \", \"\"))\n        url = 'https:\/\/{bucket}.s3-{region}.amazonaws.com\/'.format(\n                        bucket=settings.AWS_STORAGE_BUCKET_NAME,  \n                        region=settings.AWS_UPLOAD_REGION\n                        )\n        policy = base64.b64encode(policy_document_str_encoded)\n        signature = base64.b64encode(hmac.new(aws_secret, policy, hashlib.sha1).digest())\n        data = {\n            \"policy\": policy,\n            \"signature\": signature,\n            \"key\": settings.AWS_ACCESS_KEY_ID,\n            \"file_bucket_path\": upload_start_path,\n            \"file_id\": file_obj_id,\n            \"filename\": filename_final,\n            \"url\": url,\n            \"username\": username_str,\n        }\n        return Response(data, status=status.HTTP_200_OK)\n\nclass FileUploadCompleateHander(APIView):\n    permmison_classes = &#91;authentication.SessionAuthentication]\n    def post(self,*args, **kwargs):\n        video_id = self.request.POST.get('file')\n        size = self.request.POST.get('fileSize')\n        \n        data = {}\n        type_ = self.request.POST.get('fileType')\n        if video_id:\n            video = Video.objects.get(id=int(video_id))\n            video.save()\n            data&#91;'id'] = video.id\n            data&#91;'saved'] = True\n        return Response(data, status=status.HTTP_200_OK)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"URLpy%E3%81%AE%E8%A8%AD%E5%AE%9A\"><\/span>URL.py\u306e\u8a2d\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>from django.contrib import admin\nfrom django.urls import path, include\nfrom django.conf import settings\nfrom django.conf.urls import url\nfrom django.conf.urls.static import static\nfrom django.contrib.staticfiles.urls import staticfiles_urlpatterns\nfrom django.contrib.staticfiles.urls import static\nfrom GRC.views import FilePolicy,FileUploadCompleateHander\nimport GRC.views\nurlpatterns = &#91;\n    path('fhrshsssff\/', admin.site.urls),\n    path('', include('video.urls')),\n    path('api\/', include('rest_framework.urls')),\n    url(r'^api\/files\/policy\/$', FilePolicy.as_view(), name='upload-policy'),\n    url(r'^api\/files\/complete\/$',FileUploadCompleateHander.as_view(), name='upload-complete'),\n]\nurlpatterns += staticfiles_urlpatterns()<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"javascript%E3%81%A8html%E3%81%AE%E8%A8%AD%E5%AE%9A\"><\/span>javascript\u3068html\u306e\u8a2d\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>base.html\u3092\u8a2d\u5b9a\u3057\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30bf\u30b0\u3092\u5165\u529b\u3059\u308c\u3070\u3069\u306e\u30da\u30fc\u30b8\u3067\u3082\u3053\u306e\u753b\u9762\u3067\u8868\u793a\u3067\u304d\u308b\u69d8\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;html lang=\"en\"&gt;\n  &lt;head&gt;\n    &lt;!-- Required meta tags --&gt;\n    &lt;meta charset=\"utf-8\"&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\"&gt;\n    &lt;title&gt;CFE Upload&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;div class='container main-container'&gt;\n      {% block content %}{% endblock content %}\n    &lt;\/div&gt;\n    &lt;script src=\"https:\/\/code.jquery.com\/jquery-3.2.1.min.js\"&gt;&lt;\/script&gt; &lt;!-- Ensure it's not jquery-3.2.1.slim.min.js --&gt;\n  &lt;\/body&gt;\n &lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%82%A2%E3%83%83%E3%83%97%E3%83%AD%E3%83%BC%E3%83%89%E3%83%9A%E3%83%BC%E3%82%B8%E3%81%AE%E4%BD%9C%E6%88%90\"><\/span>\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30da\u30fc\u30b8\u306e\u4f5c\u6210<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script src=\"{% static 'app\/video_upload.js' %}\"&gt;&lt;\/script&gt;\n&lt;form  method=\"POST\" enctype=\"multipart\/form-data\" class='cfeproj-upload-form' id=\"my-awesome-dropzone\" enctype=\"multipart\/form-data\" &gt;\n    &lt;input class=\"cfeproj-upload-file\" id=\"video\"type=\"file\" style=\"display:none\" accept=\".MOV, .MP4, .mpeg4\"&gt;\n    &lt;div class=\"image-upload-wrap\"&gt;\n        &lt;div class=\"drag-text\" id=\"my-awesome-dropzone\"&gt;\n            &lt;label for=\"video\"&gt;&lt;h3&gt;Select add Movie&lt;\/h3&gt;&lt;\/label&gt;\n        \n      &lt;\/div&gt;\n&lt;\/div&gt;\n&lt;\/form&gt;<\/code><\/pre>\n\n\n\n<p>label for=&#8221;id&#8221; \u3067\u81ea\u5206\u306e\u671b\u3080\u30c7\u30b6\u30a4\u30f3\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>javascript<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$(document).ready(function(){\n\n    \/\/ setup session cookie data. This is Django-related\n    function getCookie(name) {\n        var cookieValue = null;\n        if (document.cookie &amp;&amp; document.cookie !== '') {\n            var cookies = document.cookie.split(';');\n            for (var i = 0; i &lt; cookies.length; i++) {\n                var cookie = jQuery.trim(cookies&#91;i]);\n                \/\/ Does this cookie string begin with the name we want?\n                if (cookie.substring(0, name.length + 1) === (name + '=')) {\n                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));\n                    break;\n                }\n            }\n        }\n        return cookieValue;\n    }\n    var csrftoken = getCookie('csrftoken');\n    function csrfSafeMethod(method) {\n        \/\/ these HTTP methods do not require CSRF protection\n        return (\/^(GET|HEAD|OPTIONS|TRACE)$\/.test(method));\n    }\n    $.ajaxSetup({\n        beforeSend: function(xhr, settings) {\n            if (!csrfSafeMethod(settings.type) &amp;&amp; !this.crossDomain) {\n                xhr.setRequestHeader(\"X-CSRFToken\", csrftoken);\n            }\n        }\n    });\n    \/\/ end session cookie data setup. \n\n\n\n\/\/ declare an empty array for potential uploaded files\nvar fileItemList = &#91;]\n\n\/\/ auto-upload on file input change.\n$(document).on('change','.cfeproj-upload-file', function(event){\n    var selectedFiles = $(this).prop('files');\n    formItem = $(this).parent()\n    $.each(selectedFiles, function(index, item){\n        var myFile = verifyFileIsImageMovieAudio(item)\n        if (myFile){\n            uploadFile(myFile)\n        } else {\n            \/\/ alert(\"Some files are invalid uploads.\")\n        }\n    })\n    $(this).val('');\n\n})\n\n\n\nfunction verifyFileIsImageMovieAudio(file){\n    \/\/ verifies the file extension is one we support.\n    var extension = file.name.split('.').pop().toLowerCase(); \/\/file.substr( (file.lastIndexOf('.') +1) );\n    switch(extension) {\n        case 'mov':\n        case 'mp4':\n        case 'mpeg4':\n            return file\n        default:\n            notAllowedFiles.push(file)\n            return null\n    }\n};\n\nfunction constructFormPolicyData(policyData, fileItem) {\n   var contentType = fileItem.type != '' ? fileItem.type : 'application\/octet-stream'\n    var url = policyData.url\n    var filename = policyData.filename\n    var repsonseUser = policyData.user\n    \/\/ var keyPath = 'www\/' + repsonseUser + '\/' + filename\n    var keyPath = policyData.file_bucket_path\n    var fd = new FormData()\n    fd.append('key', keyPath + filename);\n    fd.append('acl','private');\n    fd.append('Content-Type', contentType);\n    fd.append(\"AWSAccessKeyId\", policyData.key)\n    fd.append('Policy', policyData.policy);\n    fd.append('filename', filename);\n    fd.append('Signature', policyData.signature);\n    fd.append('file', fileItem);\n    return fd\n}\n\nfunction fileUploadComplete(fileItem, policyData){\n    data = {\n        uploaded: true,\n        fileSize: fileItem.size,\n        file: policyData.file_id,\n\n    }\n    $.ajax({\n        method:\"POST\",\n        data: data,\n        url: \"\/api\/files\/complete\/\",\n        success: function(data){\n            displayItems(fileItemList)\n        },\n        error: function(jqXHR, textStatus, errorThrown){ \n            alert(\"An error occured, please refresh the page.\")\n        }\n    })\n}\n\nfunction displayItems(fileItemList){\n    var itemList = $('.item-loading-queue')\n    itemList.html(\"\")\n    $.each(fileItemList, function(index, obj){\n        var item = obj.file\n        var id_ = obj.id\n        var order_ = obj.order\n        var html_ = \"&lt;div class=\\\"progress\\\"style=\\\"height: 20px;\\\"&gt;\" + \n          \"&lt;div class=\\\"progress-bar bg-info\\\" role=\\\"progressbar\\\" style='width:\" + item.progress + \"%' aria-valuenow='\" + item.progress + \"' aria-valuemin=\\\"0\\\" aria-valuemax=\\\"100\\\"&gt;&lt;\/div&gt;&lt;\/div&gt;\"\n        itemList.append(\"&lt;div&gt;\" + order_ + \") \" + item.name + \"&lt;a href='#' class='srvup-item-upload float-right' data-id='\" + id_ + \")'&gt;X&lt;\/a&gt; &lt;br\/&gt;\" + html_ + \"&lt;\/div&gt;&lt;hr\/&gt;\")\n\n    })\n\n\n    var InputFile = $('#video-edit')\n    var Loading = $('#loading')\n\n    InputFile.hide()\n    Loading.show()\n    \n}\n\n\nfunction uploadFile(fileItem){\n        var policyData;\n        var newLoadingItem;\n        \/\/ get AWS upload policy for each file uploaded through the POST method\n        \/\/ Remember we're creating an instance in the backend so using POST is\n        \/\/ needed.\n        $.ajax({\n            method:\"POST\",\n            data: {\n                filename: fileItem.name\n            },\n            url: \"\/api\/files\/policy\/\",\n            success: function(data){\n                    policyData = data\n            },\n            error: function(data){\n                alert(\"An error occured, please try again later\")\n            }\n        }).done(function(){\n            \/\/ construct the needed data using the policy for AWS\n            var fd = constructFormPolicyData(policyData, fileItem)\n            \n            \/\/ use XML http Request to Send to AWS. \n            var xhr = new XMLHttpRequest()\n\n            \/\/ construct callback for when uploading starts\n            xhr.upload.onloadstart = function(event){\n                var inLoadingIndex = $.inArray(fileItem, fileItemList)\n                if (inLoadingIndex == -1){\n                    \/\/ Item is not loading, add to inProgress queue\n                    newLoadingItem = {\n                        file: fileItem,\n                        id: policyData.file_id,\n                        order: fileItemList.length + 1\n                    }\n                    fileItemList.push(newLoadingItem)\n                  }\n                fileItem.xhr = xhr\n            }\n\n            \/\/ Monitor upload progress and attach to fileItem.\n            xhr.upload.addEventListener(\"progress\", function(event){\n                if (event.lengthComputable) {\n                 var progress = Math.round(event.loaded \/ event.total * 100);\n                    fileItem.progress = progress\n                    displayItems(fileItemList)\n                }\n            })\n\n            xhr.upload.addEventListener(\"load\", function(event){\n                var EditFile = $(\"#reload\")\n                EditFile.html(\"&lt;div class=\\\"btn btn-info\\\" onclick=\\\"window.location.reload();\\\"&gt;Push me&lt;\/div&gt;\")\n                var text = $(\"#modal-text\")\n                text.html(\"Upload complete. Please push reload button or &#91;push me!] Button.\")\n                \/\/ handle FileItem Upload being complete.\n                fileUploadComplete(fileItem, policyData)\n            })\n\n\n            xhr.open('POST', policyData.url , true);\n            xhr.send(fd);\n            \n        })\n}});<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306e\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002\u5fdc\u7528\u3057\u3066\u3044\u304f\u3068\u3053\u3093\u306a\u611f\u3058\u3067\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"398\" src=\"https:\/\/www.sea2800.com\/wp-content\/uploads\/2021\/09\/295edddd2fce17fa142f9634bb747ece-1024x398.png\" alt=\"\" class=\"wp-image-638\" srcset=\"https:\/\/www.sea2800.com\/wp-content\/uploads\/2021\/09\/295edddd2fce17fa142f9634bb747ece-1024x398.png 1024w, https:\/\/www.sea2800.com\/wp-content\/uploads\/2021\/09\/295edddd2fce17fa142f9634bb747ece-300x117.png 300w, https:\/\/www.sea2800.com\/wp-content\/uploads\/2021\/09\/295edddd2fce17fa142f9634bb747ece-768x299.png 768w, https:\/\/www.sea2800.com\/wp-content\/uploads\/2021\/09\/295edddd2fce17fa142f9634bb747ece-830x323.png 830w, https:\/\/www.sea2800.com\/wp-content\/uploads\/2021\/09\/295edddd2fce17fa142f9634bb747ece-230x89.png 230w, https:\/\/www.sea2800.com\/wp-content\/uploads\/2021\/09\/295edddd2fce17fa142f9634bb747ece-350x136.png 350w, https:\/\/www.sea2800.com\/wp-content\/uploads\/2021\/09\/295edddd2fce17fa142f9634bb747ece-480x187.png 480w, https:\/\/www.sea2800.com\/wp-content\/uploads\/2021\/09\/295edddd2fce17fa142f9634bb747ece.png 1152w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u3053\u308c\u3092\u3084\u308a\u305f\u304c\u308b\u4eba\u306f\u3042\u307e\u308a\u3044\u306a\u3055\u305d\u3046\u3067\u3059\u304c\u53c2\u8003\u306b\u306a\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<!-- test -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-7910153846163820\" data-ad-slot=\"9115942114\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Google\u306eGAE\uff08Google App  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,8],"tags":[],"class_list":["post-613","post","type-post","status-publish","format-standard","hentry","category-django","category-python"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.sea2800.com\/index.php?rest_route=\/wp\/v2\/posts\/613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sea2800.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sea2800.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sea2800.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sea2800.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=613"}],"version-history":[{"count":24,"href":"https:\/\/www.sea2800.com\/index.php?rest_route=\/wp\/v2\/posts\/613\/revisions"}],"predecessor-version":[{"id":1533,"href":"https:\/\/www.sea2800.com\/index.php?rest_route=\/wp\/v2\/posts\/613\/revisions\/1533"}],"wp:attachment":[{"href":"https:\/\/www.sea2800.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sea2800.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sea2800.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}