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