vidwanco / tenant-buckets

Automatic AWS bucket provisioning for each tenant
MIT License
23 stars 6 forks source link

Doesn't work on Laravel Vapor #8

Open l4nos opened 2 years ago

l4nos commented 2 years ago

For some reason this isn't working on Laravel Vapor

The below error occurs during bucket creation:

{ "message": "Error: The authorization header is malformed; a non-empty Access Key (AKID) must be provided in the credential.", "context": { "aws_request_id": "e16b9054-cf45-58fb-aead-cab8f3dca600" }, "level": 400, "level_name": "ERROR", "channel": "staging", "datetime": "2022-05-04T08:33:44.397223+00:00", "extra": {} }

l4nos commented 2 years ago

config('filesystems.disks.s3.key') returns null when creating the bucket. Tested via console command. Works on local server but not on Vapor.

l4nos commented 2 years ago

$this->credentials = $credentials ?? new Credentials( config('filesystems.disks.s3.key'), config('filesystems.disks.s3.secret') );

Needs to change to

$this->credentials = $credentials ?? CredentialProvider::env();

In tenant-buckets\src\Bucket.php

secrethash commented 2 years ago

I haven't yet had a chance to use it with Laravel Vapor yet. A pull request is always welcome 😁

Note: Do test for Laravel Vapor before creating a pull request. It would really be appreciated.

l4nos commented 2 years ago

I'm currently using my version on 3 different laravel vapor instances. Working a charm. I have changed the namespace to my own, and also made a few other changes such as setting appropriate CORS permissions on buckets (as on serverless you have to stream large files to S3 which requires adequate CORS permissions set).

Happy to do a merge or branch this off to my own package, as I have further changes to make which kind of make this more of a specialist package for Vapor users.

Let me know your thoughts.

msucevan commented 6 months ago

I'm currently using my version on 3 different laravel vapor instances. Working a charm. I have changed the namespace to my own, and also made a few other changes such as setting appropriate CORS permissions on buckets (as on serverless you have to stream large files to S3 which requires adequate CORS permissions set).

Happy to do a merge or branch this off to my own package, as I have further changes to make which kind of make this more of a specialist package for Vapor users.

Let me know your thoughts.

Can you please create a PR if you have a working solution? Many thanks!