Multiple files in a multipart/form-data upload


#1

No sure how to express a multipart/form-data upload where the user can upload arbitrary many files in one post. I could only find the section for a single file upload in the spec and in the forum. Any advice would be much appreciated. Thank you.


#2

Hello,

Try this sample:

  post:
    description: Adds any files      
    body:
    multipart/form-data: 
      formParameters:
        file:
          description: This is the file content to be uploaded
          type: file
          repeat: true

#3

As repeat is no longer supported by RAML 1.0. I’m wondering if this right way to describe that API allows multiple file uploads but atleast 1 ?
Is there any better way than using array [] because I would like to know how parsers will interpret arrays as multiple form fields ?

  uploadfile:
    type: file

      multipart/form-data:
        properties:
          file:
            type: uploadfile[]
            required: true
            minItems: 1

#4

I believe so… that is how I would do it. Not sure if that results in a string with comma separated data or not, but I suspect that would be up to the generated client and/or server side generator on how it transforms the [] type.