使用 AWS PHP SDK 时,php file_exists 不起作用
•浏览 1
php file_exists doesnt work when working with AWS PHP SDK
我正在使用 AWS PHP SDK 从 S3 存储桶中获取对象。
当我查看文件系统时,文件存在但函数 file_exist 返回 false。
如果我再次运行脚本,它将找到文件。
$result = $client->getObject(array(
'Bucket' =>"uploads/$id",
'Key' => $file,
'SaveAs' =>"somepath/$id/$file"
));
echo json_encode(file_exists("somepath/$id/$file"));
echo json_encode(file_exists("somepath/$id/$file"));
这将返回 FALSE,但如果我再次运行脚本并手动插入 url,它将返回 TRUE。
是不是在脚本仍在运行时我无法获取文件? (可能是时间问题?)
thx
您要查找的方法是 file_exists,而不是 file_exist
$result = $client->getObject(array(
'Bucket' =>"uploads/$id",
'Key' => $file,
'SaveAs' =>"somepath/$id/$file"
));
echo json_encode(file_exists("somepath/$id/$file"));
echo json_encode(file_exists("somepath/$id/$file"));