1
我試圖上傳文件到我的存儲桶。我能夠上傳Body,但不是SourceFile。這裏是我的方法:SourceFile亞馬遜AWS S3
$pathToFile='/explicit/path/to/file.jpg'
// Upload an object by streaming the contents of a file
$result = $s3Client->putObject(array(
'Bucket' => $bucket,
'Key' => 'test.jpg',
'SourceFile' => $pathToFile,
'ACL' => 'public-read',
'ContentType' => 'image/jpeg'
));
,但我得到這個錯誤:
You must specify a non-null value for the Body or SourceFile parameters.
我已經嘗試不同類型的文件,並保持收到此錯誤。
這可能是具有打開該文件的問題。試試''Body'=> fopen($ pathToFile,'r')',看看是否有打開文件的問題。 – 2014-12-05 17:40:32
'Invalid resource type' is the error I get for that method – Riftus 2014-12-05 17:42:26
那麼'var_dump(fopen($ pathToFile,'r'))'看起來像什麼?它不能返回有效的資源。 – 2014-12-05 20:47:54