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

Cannot upload an image #383

Open
Zander1983 opened this issue Jan 22, 2021 · 0 comments
Open

Cannot upload an image #383

Zander1983 opened this issue Jan 22, 2021 · 0 comments

Comments

@Zander1983
Copy link

Im having trouble uploading an image. My swagger definition is:

'/orders-logo':
   post:
     x-swagger-router-controller: OrdersController
     tags:
       - orders
     summary: This API is upload a logo
     operationId: uploadLogo
     consumes:
       - multipart/form-data
     produces:
       - application/json
     parameters:
       - name: file
         in: formData
         description: file to upload
         required: false
         type: file
     responses:
       '200':
         description: Success
         schema:
           $ref: '#/definitions/TokenView'
       '400':
         description: The request doesn't comply with the schema specified
         schema:
           $ref: '#/definitions/ApiError'
       '401':
         description: Missing or invalid Authorization header
         schema:
           $ref: '#/definitions/ApiError'
       '500':
         description: Internal server error while processing the request
         schema:
           $ref: '#/definitions/ApiError'

And my method in the Controller:

    public ResponseContext uploadLogo(RequestContext context, java.io.InputStream file) {
        ResponseContext response = new ResponseContext().contentType(MediaType.APPLICATION_JSON_TYPE);
        System.out.println("in here");
    }

And I'm trying a few different CURLs:

curl -i -X POST \
-H "Content-Type: multipart/form-data" \
-H 'Authorization: eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhbm9uXzU3MjBmMGUzLTMxMzItNDQ1OC1hYjYyLTBmY2EwMDEyMjAyNCIsImlzcyI6IkNsZXZlcmdpZnQiLCJleHAiOjE2MTY1MjEwMjMsImJhc2ljIjoidHJ1ZSIsIm1lcmNoYW50IjoiaGlnaHN0cmVldHZvdWNoZXJzIn0.s-yukQincZoWevQARLNrl57SABAetBxMCOF39RSd7a7tEnds5pIgo5ekRTQgX98MlEXFyDoHe0ws7iMIo_-cOQ' \
-H 'Api-Key: 7a34526370e2c3d4f2784f874aacbc0b' \
-F "[email protected]" "http://localhost:8080/v1/orders-logo"

and:

curl --location --request POST 'http://localhost:8080/v1/orders-logo' \
--header 'Api-Key: 7a34526370e2c3d4f2784f874aacbc0b' \
--header 'Content-Type: multipart/form-data' \
--header 'Authorization: eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhbm9uXzU3MjBmMGUzLTMxMzItNDQ1OC1hYjYyLTBmY2EwMDEyMjAyNCIsImlzcyI6IkNsZXZlcmdpZnQiLCJleHAiOjE2MTY1MjEwMjMsImJhc2ljIjoidHJ1ZSIsIm1lcmNoYW50IjoiaGlnaHN0cmVldHZvdWNoZXJzIn0.s-yukQincZoWevQARLNrl57SABAetBxMCOF39RSd7a7tEnds5pIgo5ekRTQgX98MlEXFyDoHe0ws7iMIo_-cOQ' \
--form '=@"/Users/markkelly/Pictures/download.jpeg"'

But I get:

{"code":404,"message":"HTTP 404 Not Found"} back from the server.

Im using swagger-inflector version 1.0.17. Any ideas what I am doing wrong?

@webron webron transferred this issue from swagger-api/swagger-samples Jan 22, 2021
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

1 participant