teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

詳細のエラーを追記

2016/12/13 02:59

投稿

CyberMergina
CyberMergina

スコア295

title CHANGED
File without changes
body CHANGED
@@ -127,13 +127,12 @@
127
127
  }
128
128
  ```
129
129
 
130
- ファイルが開けないと怒られました・・・。
130
+ ハッシュの形式が違う?とかでファイルが開けないと怒られました・・・。
131
131
 
132
132
  ```php
133
- object(RuntimeException)[276]
134
- protected 'message' => string 'Unable to open �����JFIF��H�H�����C� 
133
+ A sha256 checksum could not be calculated for the provided upload body, because it was not seekable. To prevent this error you can either 1) include the ContentMD5 or ContentSHA256 parameters with your request, 2) use a seekable stream for the body, or 3) wrap the non-seekable stream in a GuzzleHttp\Psr7\CachingStream object. You should be careful though and remember that the CachingStream utilizes PHP temp streams. This means that the stream will be temporarily stored on the local disk.
135
134
 
136
135
  ```
137
136
 
138
137
 
139
- [一旦ファイルを生成してからアップするしかない?](https://forums.aws.amazon.com/thread.jspa?threadID=77595)みたいですかね・・・
138
+ [一旦ファイルを生成してからアップする](https://forums.aws.amazon.com/thread.jspa?threadID=77595)方が良いみたいですかね・・・

2

追記1:putObjectでファイルを送るようにしてみる

2016/12/13 02:59

投稿

CyberMergina
CyberMergina

スコア295

title CHANGED
File without changes
body CHANGED
@@ -102,4 +102,38 @@
102
102
 
103
103
  以上です。
104
104
  足りない情報等あれば、随時追記させて頂きますので
105
- ご教授の程よろしくお願い致します。
105
+ ご教授の程よろしくお願い致します。
106
+
107
+
108
+ ###追記1
109
+
110
+ putObjectでアップするように、ソースコードを下記の通り変更してみました。
111
+
112
+ ```php
113
+ private function _createThumnail($fileName){
114
+ $thumbname = "thumb_".pathinfo($fileName, PATHINFO_FILENAME).".jpg"; //サムネイルのファイル名
115
+ /* 画像の読み込み */
116
+ $thumbImg = new Imagick();
117
+ /* サムネイルの作成 */
118
+ $thumbImg->readImage(AWS_S3_HOSTNAME.AWS_S3_BUCKET."/xxxx/".$fileName);
119
+ $thumbImg->thumbnailImage(100, 0);
120
+ $thumbImg->setImageFormat ("jpeg");
121
+ try {
122
+ $ret = $this->Amazon->putObject("xxxx/".$thumbname, $thumbImg->getImageBlob());
123
+ } catch (Exception $e) {
124
+ }
125
+ $thumbImg->clear();
126
+ return $ret;
127
+ }
128
+ ```
129
+
130
+ ファイルが開けないと怒られました・・・。
131
+
132
+ ```php
133
+ object(RuntimeException)[276]
134
+ protected 'message' => string 'Unable to open �����JFIF��H�H�����C� 
135
+
136
+ ```
137
+
138
+
139
+ [一旦ファイルを生成してからアップするしかない?](https://forums.aws.amazon.com/thread.jspa?threadID=77595)みたいですかね・・・

1

補足を追記しました。

2016/12/13 02:35

投稿

CyberMergina
CyberMergina

スコア295

title CHANGED
File without changes
body CHANGED
@@ -20,6 +20,9 @@
20
20
  ```
21
21
 
22
22
  ###該当のソースコード
23
+
24
+ DocumentController.php
25
+
23
26
  ```php
24
27
 
25
28
  private function _createThumnail($fileName){
@@ -43,7 +46,9 @@
43
46
  }
44
47
  ```
45
48
 
46
- ```php:AmazonComponent.php
49
+ AmazonComponent.php
50
+
51
+ ```php
47
52
  function putObject($key, $file){
48
53
  try {
49
54
  $credentials = new Credentials(AWS_S3_KEY, AWS_S3_SECURITY);