My laravel applikation is based on jetstream and inertia vue3 (option api +vite). Using Laravel Vapor to host serverless on aws.
I store files using successfully on my aws s3 bucket, in my tmp folder. So far, soo good.
How can I create a subfolder in tmp while uploading? In bestcase, the subfolder get the userID from auth.
store function
const store = () => {
Vapor.store(form.file, {
visibility: 'public-read',
progress: progress => {
form.processing = Math.round(progress * 100);
}
}).then(response => {
axios.post('file-upload-store-aws', {
uuid: response.uuid,
key: response.key,
bucket: response.bucket,
name: form.file.name,
content_type: response.extension,
}).then( () => {
form.reset();
form.processing = 0;
}
);
});
}
route
Route::post('file-upload-store-aws', function () {
Storage::disk('s3')->copy(
request()->key,
Auth::id()
);
});
I tried put instead of copy like this:
Storage::disk('s3')->put(
'/subfolder/' . request()->key,
Auth::id()
);
The upload still works, but without a subfolder.
EDIT:
I did some progress. But still not a subfolder of tmp
// SAVE FILES ON AWS
Route::post('file-upload-store-aws', function () {
$currentUser = Auth::id();
Storage::makeDirectory($currentUser);
Storage::disk('s3')->put(
$currentUser . '/' . request()->name,
Auth::id()
);
});