AWS S3 文件上传但存储桶中的文件没有大小?

AWS S3 file uploads but files in bucket has no size?

大家好。我想将多个图像文件上传到我的 S3 存储桶,我可以这样做。将文件上传到我的 AWS S3 存储桶后,我遇到的唯一问题是文件在那里,但所有图像文件的大小都为 0。什么可能导致此问题?我使用的是最新版本的 AWS S3 Php SDK,下面的代码将大致演示我的尝试: Amazon S3 Dashboard

//Get all our files
$allFiles = $_FILES['files'];

//create an array to store all of our commands
$commands = array();
$imgURLArray = array();
$temp_files_array=array();


for($i=0; $i<count($_FILES['files']['name']); $i++) 
{    
    //properties for creating nd placing the temporary file:
    $name = $allFiles['name'][$i]; // Get the origanal img name
    $tmp_name = $allFiles['tmp_name'][$i]; //get the original temp_name
    $extension = explode('.', $name);  // get the file extension
    $extension = strtolower(end($extension)); //make sure the extension is in lowercase
    $randomGeneratedName = md5(uniqid()); // Generate a new unique name for our temp file 
    $tmp_file_path = "../../tmp_files/{$randomGeneratedName}.{$extension}"; 

    //move our temporary to the temp_folder file
    move_uploaded_file($tmp_name, $tmp_file_path);

    //Bucket properties
    $bucket = $config["buckets"]['mybucket'];
    $path =  $config["product"]['path'];
    $imgName= 'product'. $productID.$i.'.'.$extension;
    $body = fopen($tmp_file_path, 'rb');
    $acl = 'public-read';

    //Command parameters
    $objParams = 
    [
        'Bucket' => $bucket,
        'Key' => $path.$imgName,
        'body' => $body,
        'ACL' => $acl
    ];

      $commands[] = $s3Client->getCommand('PutObject', $objParams);
      $url = $config['bucket']['url'].$path.$imgName;
      array_push($temp_files_array,$tmp_file_path);
      array_push($imgURLArray, $url);
}

 $pool = new CommandPool($s3Client,$commands);
 $promise = $pool->promise();
 $promise->wait();

如此荒谬的问题和解决方案...

在我的 $objParams 数组中,我用小写字母 "b" 声明了 "Body" 键,而不是使用大写 "B",所以该数组的正确版本是这样的:

$objParams = 
[
 'Bucket' => $bucket,
 'Key' => $path.$name,
 'Body' => $body,
  'ACL' => $acl
];