How to use the AWS SDK for Laravel with Stook?
Integrate Medianova Stook Object Storage into your Laravel application using the AWS SDK.
Last updated
Was this helpful?
Was this helpful?
'providers' => [
Aws\Laravel\AwsServiceProvider::class,
],
'aliases' => [
'AWS' => Aws\Laravel\AwsFacade::class,
],php artisan vendor:publish --provider="Aws\Laravel\AwsServiceProvider"return [
'credentials' => [
'key' => env('YOUR_STOOK_ACCESS_KEY_ID'),
'secret' => env('YOUR_STOOK_SECRET_ACCESS_KEY'),
],
'region' => env('YOUR_STOOK_REGION', 'us-east-1'),
'version' => 'latest',
'ua_append' => [
'L5MOD/' . AwsServiceProvider::VERSION,
],
'endpoint' => env('YOUR_STOOK_ENDPOINT'),
'use_path_style_endpoint' => true,
'http' => [
'verify' => false
]
];YOUR_STOOK_ACCESS_KEY_ID=xxxxxxxxxxxxxxxx
YOUR_STOOK_SECRET_ACCESS_KEY=yyyyyyyyyyyyyyyyyyyy
YOUR_STOOK_ENDPOINT=https://xxxxx.mncdn.compublic function uploadStookFile(Request $request)
{
// File information
$fileExtension = $request->file('image')->getClientOriginalExtension();
$fileFullName = "testFile" . '.' . $fileExtension;
try {
$s3 = App::make('aws')->createClient('s3');
$s3->putObject([
'Bucket' => "test-bucket",
'Key' => $fileFullName,
'SourceFile' => $request->file('image')->getRealPath(),
]);
} catch (\Exception $exception) {
throw new \Exception('File could not upload to Stook account.');
}