theUnforgiven
6 months ago
1389
9
Vapor

Vapor uploading files

Posted 6 months ago by theUnforgiven

Hi all,

I have my AWS all setup in .env and Vapor deploy all works etc. But I have a new Vue component, to upload files.

<template>
    <div class="mt-2 mb-2 mr-2">
        <input type="file" id="file" ref="file" @change="upload" class="form-control">
        <div v-if="isUploaded">
            <div class="alert alert-success">File uploaded successfully</div>
        </div>
    </div>
</template>

<script>
    export default {

        data() {
            return {
                isUploaded: false,
            }
        },

        methods: {
            upload() {
                Vapor.store(this.$refs.file.files[0], {
                    progress: progress => {
                        this.uploadProgress = Math.round(progress * 100);
                    }
                }).then(response => {
                    console.log(response)
                    axios.post('/api/file/upload', {
                        uuid: response.uuid,
                        key: response.key,
                        bucket: response.bucket,
                        name: this.$refs.file.files[0].name,
                        content_type: this.$refs.file.files[0].type,
                    })

                    this.isUploaded = true;
                });
            }
        }
    }
</script>

But I'm seeing these errors and not sure why, as I have followed the Vapor docs.

Any help greatly appreciated

cc @themsaid

Please sign in or create an account to participate in this conversation.