Laravel 5.5 app. I need to retrieve images of driver's licenses from Amazon S3 (already working) and then upload it to Stripe using their api for identity verification (not working).
Stripe's documents give this example:
\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)
);
However, I am not retrieving my files using fopen()
. When I retrieve my image from Amazon S3 (using my own custom methods), I end up with an instance of Intervention\Image
-- essentially, Image::make($imageFromS3)
-- and I don't know how to convert this to the equivalent of the call to fopen('/path/to/a/file.jpg', 'r')
. I have tried the following:
$image->stream()
$image->stream()->__toString()
$image->stream('data-url')
$image->stream('data-url')->__toString()
I have also tried skipping intervention image and just using Laravel's storage retrieval, for example:
$image = Storage::disk('s3')->get('path/to/file.jpg');
All of these approaches result in getting an Invalid hash
exception from Stripe.
What is the proper way to get a file from S3 and convert it to the equivalent of the fopen()
call?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire