I am realy confused about Google Cloud Storage. I am not a programmer so I use Laravel and a Cloud Storage Client for PHP.
https://github.com/googleapis/google-cloud-php-storage
What I am trying to do:
A photographer is uploading a preview file, anyone can view this and it stored in my default bucket.
\Illuminate\Support\Facades\Storage::disk(env('FILESYSTEM_DRIVER'))->put(
'storage' . DIRECTORY_SEPARATOR . $filename,
file_get_contents($filename),
\Illuminate\Contracts\Filesystem\Filesystem::VISIBILITY_PUBLIC
);
Then a photographer is uploading a zipfile with all pics, lets say to a bucket named "downloads". Someone who payed for it can click on a link to download it. How can I mask the filename and make sure the url is not shared? I could make a route where the user is signed in.
Route::group(['middleware' => ['role:user|store']], function() {
Route::get('download/{orderid}', [
'as' => 'download-link',
'uses' => 'OrderController@download'
]);
});
Some totaly psuedo code inside controller action, I don't what I am doing here... I don't even know how to get the object (file)...
$query = DB::table('orders')->where('id', $request->get('orderid'))
->where('userid', Auth::user()->id)
->firstOrFail()->pluck('realfilename');
$reponse = Storage::disk('gcs')
->bucket('downloads')
->getObject($query['realfilename']);
return Storage::download('file.jpg', $name, ['Content-Type: application/zip']);