Upload multiple file ("allowMultiple":True)

Skip to first unread message

crispy

unread,
Jul 14, 2015, 3:20:27 AM7/14/15
to swagger-sw...@googlegroups.com

I am currently doing multiple files upload using swagger operation. Following are the codes that I am working with:

class uploadImage(Resource):

  @swagger.operation(

        notes='Upload an image file',

        parameters=[
          {
            "name": "file[]",
            "description": "Upload an image file. File size limit is 3MB. Only '.jpg' is allowed ",
            "required": True,
            "allowMultiple": True,
            "dataType": 'file',
            "paramType": "form"
          }
])

  def post(self):
    files=request.files.getlist['file[]']
    filenames = []
    for file in files:
        filename = secure_filename(file.filename)
        filenames.append(filename)
        print "Files are uploaded successfully"

Although I inserted "allowMultiple":True in the code, but it did not show in the swagger UI. Once the server is up, I try to view the html source code, "multiple" does not display in the form.

Following is the source code for swagger ui when the server is up:

<input class="parameter" type="file" name="file[]">

The word "multiple" is missing from the .

If I edit the source code and add in the word "multiple" as below, I manage to select multiple files.

<input class="parameter" type="file" name="file[]" multiple>

It seems like "allowMultiple":True does not work for me in this case.

Any idea or suggestion for me?

Thank you.

Ron Ratovsky

unread,
Jul 14, 2015, 3:21:48 AM7/14/15
to swagger-sw...@googlegroups.com
Unfortunately, that can't be done due to a limitation in the spec - https://github.com/swagger-api/swagger-spec/issues/254.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-----------------------------------------
http://swagger.io
https://twitter.com/SwaggerApi
-----------------------------------------

crispy

unread,
Jul 14, 2015, 4:29:02 AM7/14/15
to swagger-sw...@googlegroups.com
Thanks for replying, Ron.
Mean that by using swagger UI, we are not able to upload multiple files at one time? 
I saw this link, is an application using Flask, it is able to upload multiple files. They have their view (html) and script (.py) separately. Can I have an alternative that can upload multiple files using swagger UI?

Ron Ratovsky

unread,
Jul 14, 2015, 6:56:43 AM7/14/15
to swagger-sw...@googlegroups.com
The problem is that the spec doesn't support it, so the ui doesn't support it. You can add any number of parameters that are files, but you can't upload any number of files.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

crispy

unread,
Jul 15, 2015, 3:10:59 AM7/15/15
to swagger-sw...@googlegroups.com
Ok.Got it.
Thanks for replying, Ron.


On Tuesday, July 14, 2015 at 3:20:27 PM UTC+8, crispy wrote:
Reply all
Reply to author
Forward
0 new messages