Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata plugin doesn't work #156

Open
gdinko opened this issue May 26, 2020 · 3 comments
Open

Metadata plugin doesn't work #156

gdinko opened this issue May 26, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@gdinko
Copy link

gdinko commented May 26, 2020

Summary

Hi, i am building laravel app for image upload to products and i need to pass product_id to backend to know for witch product are the images that are uploaded.

How to reproduce

Fresh laravel app. Install filepond and plugins with npm. Create new vue component. Init FilePond and plugins.

`import vueFilePond from 'vue-filepond';
import FilePondPluginFileValidateType from 'filepond-plugin-file-validate-type/dist/filepond-plugin-file-validate-type.esm.js';
import FilePondPluginImagePreview from 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.esm.js';
import 'filepond/dist/filepond.min.css';
import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css';
import FilePondPluginFileMetadata from 'filepond-plugin-file-metadata/dist/filepond-plugin-file-metadata.esm.js';

const FilePond = vueFilePond(
FilePondPluginFileValidateType,
FilePondPluginImagePreview,
FilePondPluginFileMetadata
);`

in blade template insert the vue component

`<file-pond

            name="model_images"
            ref="pond"
            allow-multiple="true"
            accepted-file-types="image/jpeg, image/png"
            max-files="3" 
            :server="{
                process: {
                    url: this.uploadUrl,
                    method: 'POST',
                    headers: {
                        'X-CSRF-TOKEN': this.csrf
                    }
                }
            }"
            :disabled="this.disableFileUpload"
            allowFileMetadata="true"
            data-file-metadata-hello="world"
        >

        </file-pond>`

Expected behaviour

Expecting metadata: hello => world missing but always getting color => null

Additional information

When sending metadata like this:

v-on:addfile="handleFilePondAddFile"

handleFilePondAddFile: function(error, file) { file.setMetadata('model_id', this.selectedModel.model_id); },

the metadata is set , but the variable is with the same name like the file , and this is problem for laravel:

print_r($request->file('model_images')); print_r($request->model_images);

Environment Version
OS MacOS
Browser Chrome
@rikschennink
Copy link
Collaborator

Hi, by default metadata is supplied with the same name as the file field, if you want to change that you have to supply a custom server.process method.

It’s possible that the metadata plugin doesn’t pick up data properties on the Vue component, I don’t think those are passed to the internal DOM node, so that would indeed need to be fixed.

@rikschennink
Copy link
Collaborator

Just tested, it doesn't pick up the data attributes, best to use the oninitfile callback: https://codesandbox.io/s/vue-filepond-metadata-bpmlg?file=/src/components/FilePondDemo.vue

@rikschennink rikschennink added the bug Something isn't working label Jul 27, 2020
@productdevbook
Copy link

some problem vue3 and graphql send file empty data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants