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

multipleUpload stuck in pending #63

Closed
pellandaSyn opened this issue Dec 11, 2018 · 1 comment
Closed

multipleUpload stuck in pending #63

pellandaSyn opened this issue Dec 11, 2018 · 1 comment

Comments

@pellandaSyn
Copy link

Node.js version:
v11.2.0
npm version:
6.4.1
Strapi version:
3.0.0-alpha.16
Operating system:
macOS Mojave 10.14.1

Which example is causing problem?

Do you want to request a feature or report a bug?
bug
What is the current behavior?
upload plugin is missing mutation multipleUpload, i tried editing the schema.graphql , if i pass the files variables the request is stuck in pending

const _ = require('lodash');

module.exports = {
  mutation: `
    upload(refId: ID, ref: String, source: String, file: Upload!): UploadFile!,
    multipleUpload(refId: ID, ref: String, source: String, files: [Upload!]): [UploadFile!]
  `,
  resolver: {
    Query: {
      file: false,
      files: {
        description: 'Return files uploaded',
        resolver: {
          plugin: 'upload', 
          handler: 'Upload.find'
        },
      }
    },
    Mutation: {
      createFile: false,
      updateFile: false,
      deleteFile: false,
      upload: {
        description: 'Upload one file',
        resolver: async (obj, { file, ...fields}, { context }) => {
          // Construct context to fit with koa-parser guidelines
          // and avoid to update our business logic too much.
          context.request.body = {
            files: {
              files: await file
            },
            fields
          };

          // Call controller action.
          await strapi.plugins.upload.controllers.upload.upload(context);

          // Handle case when the user is uploading only one file.
          if (_.isArray(context.body) && context.body.length === 1) {
            return context.body[0];
          }

          // Return response.
          return context.body;
        }
      },
      multipleUpload: {
        description: 'Upload multiple files',
        policy: ['plugins.users-permissions.isAuthenticated', 'isOwner'],
        resolver: async (obj, { files, ...fields}, { context }) => {
            console.log('###multipleUpload')
          // Construct context to fit with koa-parser guidelines
          // and avoid to update our business logic too much.
          context.request.body = {
            files: {
              files: await files
            },
            fields
          };

          // Call controller action.
         await strapi.plugins.upload.controllers.upload.upload(context);

          // Handle case when the user is uploading only one file.
          if (_.isArray(context.body) && context.body.length === 1) {
            return context.body[0];
          }

          // Return response.
          return context.body;
        }
      },
    }
  }
};


If the current behavior is a bug, please provide the steps to reproduce the problem

What is the expected behavior?

@lauriejim
Copy link
Contributor

Duplicate strapi/strapi#2464

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants