質問編集履歴

8

訂正

2021/03/22 12:54

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -14,10 +14,6 @@
14
14
 
15
15
 
16
16
 
17
- $upload_image
18
-
19
-
20
-
21
17
  ### 発生している問題・エラーメッセージ
22
18
 
23
19
 
@@ -26,15 +22,7 @@
26
22
 
27
23
  """
28
24
 
29
- Error executing "PutObject" on "https://aroundthelaravel.s3.amazonaws.com/MY6ALhiyh682VIUiOHudOzkwF0URB8iaMP6LsYT5.jpg"; AWS HTTP error: Client error: `PUT http ▶
30
-
31
- <?xml version="1.0" encoding="UTF-8"?>
25
+ Creating default object from empty value
32
-
33
- <Error><Code>AuthorizationHeaderMalformed</Code><Message>The authorization header (truncated...)
34
-
35
- AuthorizationHeaderMalformed (client): The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'ap-northeast-1' - <?xml version="1.0" ▶
36
-
37
- <Error><Code>AuthorizationHeaderMalformed</Code><Message>The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'ap-northeast-1'</Mes ▶
38
26
 
39
27
  """
40
28
 
@@ -184,7 +172,7 @@
184
172
 
185
173
  AWS_SECRET_ACCESS_KEY='xxxxxx'
186
174
 
187
- AWS_DEFAULT_REGION=us-east-1
175
+ AWS_DEFAULT_REGION=ap-northeast-1
188
176
 
189
177
  AWS_BUCKET='xxxxxx'
190
178
 

7

訂正

2021/03/22 12:54

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -188,9 +188,15 @@
188
188
 
189
189
  AWS_BUCKET='xxxxxx'
190
190
 
191
-
192
-
193
- ```
191
+ ```
192
+
193
+
194
+
195
+ パブリックアクセス設定機能を以下のように変更
196
+
197
+
198
+
199
+ ![イメージ説明](b5d2a97a893bc9c8420fff612f39d1b1.png)
194
200
 
195
201
  ### 参考にした記事
196
202
 
@@ -199,3 +205,5 @@
199
205
  https://qiita.com/nobu0717/items/51dfcecda90d3c5958b8
200
206
 
201
207
  https://note.com/akina7/n/n69a979bef3fd
208
+
209
+ https://qiita.com/whitia/items/271ce8485df2148702df

6

訂正

2021/03/22 12:46

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -24,7 +24,19 @@
24
24
 
25
25
  ```
26
26
 
27
+ """
28
+
29
+ Error executing "PutObject" on "https://aroundthelaravel.s3.amazonaws.com/MY6ALhiyh682VIUiOHudOzkwF0URB8iaMP6LsYT5.jpg"; AWS HTTP error: Client error: `PUT http ▶
30
+
27
- The PutObject operation requires non-empty parameter: Bucket
31
+ <?xml version="1.0" encoding="UTF-8"?>
32
+
33
+ <Error><Code>AuthorizationHeaderMalformed</Code><Message>The authorization header (truncated...)
34
+
35
+ AuthorizationHeaderMalformed (client): The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'ap-northeast-1' - <?xml version="1.0" ▶
36
+
37
+ <Error><Code>AuthorizationHeaderMalformed</Code><Message>The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'ap-northeast-1'</Mes ▶
38
+
39
+ """
28
40
 
29
41
  ```
30
42
 
@@ -164,6 +176,22 @@
164
176
 
165
177
  ```
166
178
 
179
+ ### .env
180
+
181
+ ```php
182
+
183
+ AWS_ACCESS_KEY_ID='xxxxxxx'
184
+
185
+ AWS_SECRET_ACCESS_KEY='xxxxxx'
186
+
187
+ AWS_DEFAULT_REGION=us-east-1
188
+
189
+ AWS_BUCKET='xxxxxx'
190
+
191
+
192
+
193
+ ```
194
+
167
195
  ### 参考にした記事
168
196
 
169
197
 

5

訂正

2021/03/22 12:36

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -54,15 +54,11 @@
54
54
 
55
55
  if ($upload_image) {
56
56
 
57
- #$path = $upload_image->store('uploads', 'public');
58
-
59
57
  $path = Storage::disk('s3')->put('/', $upload_image, 'public');
60
58
 
61
59
  if ($path) {
62
60
 
63
- #Image::make($upload_image->getRealPath())->resize(150, 150)->save();
64
-
65
- $image = Image::make($upload_image->getRealPath());
61
+ $image->path = Storage::disk('s3')->url($path);
66
62
 
67
63
  $image->resize(150, 150);
68
64
 

4

訂正

2021/03/22 12:27

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -14,6 +14,8 @@
14
14
 
15
15
 
16
16
 
17
+ $upload_image
18
+
17
19
 
18
20
 
19
21
  ### 発生している問題・エラーメッセージ
@@ -22,7 +24,7 @@
22
24
 
23
25
  ```
24
26
 
25
- Found 1 error while validating the input provided for the PutObject operation: [Key] expected string length to be >= 1, but found string length of 0
27
+ The PutObject operation requires non-empty parameter: Bucket
26
28
 
27
29
  ```
28
30
 
@@ -52,13 +54,15 @@
52
54
 
53
55
  if ($upload_image) {
54
56
 
57
+ #$path = $upload_image->store('uploads', 'public');
58
+
55
- $path = Storage::disk('s3')->put('/', $image_file, 'public');
59
+ $path = Storage::disk('s3')->put('/', $upload_image, 'public');
56
60
 
57
61
  if ($path) {
58
62
 
63
+ #Image::make($upload_image->getRealPath())->resize(150, 150)->save();
64
+
59
65
  $image = Image::make($upload_image->getRealPath());
60
-
61
- $image->path = Storage::disk('s3')->url($path);
62
66
 
63
67
  $image->resize(150, 150);
64
68
 

3

訂正

2021/03/22 12:25

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,9 @@
10
10
 
11
11
 
12
12
 
13
- S3バケット作成、S3のパッケージをインストールは終わっていて、コントローラーの記述のみです。
13
+ S3バケット作成、S3のパッケージをインストールは終わっていて、コントローラーの記述をやっています。
14
+
15
+
14
16
 
15
17
 
16
18
 

2

訂正

2021/03/22 11:32

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -94,6 +94,50 @@
94
94
 
95
95
 
96
96
 
97
+ ### index.blade.php
98
+
99
+ ```php
100
+
101
+ @foreach ($posts as $post)
102
+
103
+ <tr>
104
+
105
+ <td>{{ optional ($post)->id }}</td>
106
+
107
+ <td>{{ optional ($post->created_at)->format('Y.m.d') }}</td>
108
+
109
+ <td>{{$post->user->name}}</td>
110
+
111
+ <td>{{ optional ($post)->subject }}</td>
112
+
113
+ <td>
114
+
115
+ @if (empty($post->image_file))
116
+
117
+
118
+
119
+ @else
120
+
121
+ <img src="{{ asset('/storage/'.$post->image_file)}}" width="150px">
122
+
123
+ @endif
124
+
125
+ </td>
126
+
127
+ <td>{!! nl2br(e(Str::limit($post->message, 100))) !!}
128
+
129
+ @if ($post->comments->count() >= 1)
130
+
131
+ <p><span class="badge badge-primary">コメント:{{ optional ($post->comments)->count() }}件</span></p>
132
+
133
+ @endif
134
+
135
+ </td>
136
+
137
+ ```
138
+
139
+
140
+
97
141
  ### filesystems.php
98
142
 
99
143
  ```php

1

訂正

2021/03/22 11:31

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- S3 コントローラーのstoreアクションの記述方法
1
+ S3の画像アップロードができない
test CHANGED
@@ -92,6 +92,32 @@
92
92
 
93
93
  ```
94
94
 
95
+
96
+
97
+ ### filesystems.php
98
+
99
+ ```php
100
+
101
+ 's3' => [
102
+
103
+ 'driver' => 's3',
104
+
105
+ 'key' => env('AWS_ACCESS_KEY_ID'),
106
+
107
+ 'secret' => env('AWS_SECRET_ACCESS_KEY'),
108
+
109
+ 'region' => env('AWS_DEFAULT_REGION'),
110
+
111
+ 'bucket' => env('AWS_BUCKET'),
112
+
113
+ 'url' => env('AWS_URL'),
114
+
115
+ 'endpoint' => env('AWS_ENDPOINT'),
116
+
117
+ ],
118
+
119
+ ```
120
+
95
121
  ### 参考にした記事
96
122
 
97
123