【发布时间】:2018-08-03 21:39:13
【问题描述】:
Laravel 5.5 应用程序。我需要从 Amazon S3 中检索驾照图像(已经可以使用),然后使用他们的 api 将其上传到 Stripe 以进行身份验证(无法使用)。
Stripe's documents 举个例子:
\Stripe\Stripe::setApiKey(PLATFORM_SECRET_KEY);
\Stripe\FileUpload::create(
array(
"purpose" => "identity_document",
"file" => fopen('/path/to/a/file.jpg', 'r')
),
array("stripe_account" => CONNECTED_STRIPE_ACCOUNT_ID)
);
但是,我没有使用 fopen() 检索我的文件。
当我从 Amazon S3 检索我的图像(使用我自己的自定义方法)时,我最终得到了一个 Intervention\Image 的实例——本质上,Image::make($imageFromS3)——我不知道如何将其转换为等效的致电fopen('/path/to/a/file.jpg', 'r')。我尝试了以下方法:
$image->stream()
$image->stream()->__toString()
$image->stream('data-url')
$image->stream('data-url')->__toString()
我也尝试过跳过干预图像,只使用 Laravel 的存储检索,例如:
$image = Storage::disk('s3')->get('path/to/file.jpg');
所有这些方法都会导致从 Stripe 获得 Invalid hash 异常。
从 S3 获取文件并将其转换为等效于 fopen() 调用的正确方法是什么?
【问题讨论】:
标签: php laravel laravel-5 stripe-connect intervention