Integrate Medianova Stook Object Storage into your Laravel application using the AWS SDK.
You can connect your Laravel application to Medianova Stook Object Storage by using the AWS SDK. This allows you to store and manage files directly in Stook through Laravel.
Laravel project installed
Composer available on your system
Medianova Stook credentials:
Access Key
Secret Key
Endpoint
Install the AWS SDK for Laravel with Composer:
Open config/app.php and register the package:
Run the following command to publish the AWS config file:
This creates config/aws.php.
Update config/aws.php with your Stook credentials:
Set your Stook credentials in .env:
Example controller method to upload files:
File not uploading: Check bucket name and credentials.
Connection error: Ensure the Stook endpoint is correct.
Permission denied: Verify Access Key and Secret Key.
composer require aws/aws-sdk-php-laravel'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.');
}