Gabriel Barros
Gabriel Barros

Reputation: 23

Laravel Vapor PHP error while trying to upload file form front-end

Error: Missing environment variables: AWS_BUCKET, AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY

i'm using laravel-vapor lib to upload files from the front-end because of his sizes(6.8mb)

my code to upload:

showAlert() {   
        alert("vou entrar");        
        try {
            
            Vapor.store(this.$refs.file.files[0], {
progress: progress => {
    this.uploadProgress = Math.round(progress * 100);
}
,visibility: 'public-read'
}).then(response => {
    axios.post('/api/tempmedia', {
        uuid: response.uuid,
        key: response.key,
        bucket: response.bucket,
        name: this.$refs.file.files[0].name,
        content_type: this.$refs.file.files[0].type,
    })
});
            } catch (error) {
                alert(error.message);
            }   

My env:

AWS_ACCESS_KEY_ID="..."
AWS_SECRET_ACCESS_KEY="..."
AWS_DEFAULT_REGION=...
AWS_REGION=...
AWS_BUCKET=...
AWS_BUCKET_URL=...

My connection is correct because i've added files from the back-end before.

I already tried php artisan config:cache and php artisan config:clear but the error continues

Upvotes: 0

Views: 561

Answers (1)

BobB
BobB

Reputation: 762

You need to pull and then push the .env for the environment you are deploying to. For production

vapor env:pull production

This will download a file(.env.production) that you can edit. Add your env variables as you would in your normal .env file. Then save and :

vapor env:push production

Then vapor deploy production

Upvotes: 0

Related Questions