Closed merforga closed 6 years ago
Related to #136
A quickie:
curl -F "username=amadan" -F "password=notmypassword" -F "20170808-224359.evtc=@/Users/amadan/Downloads/20170808-224359.evtc" https://uat.gw2raidar.com/api/upload.json
POST
, with multipart/form-data
encodingusername
field needs to contain a valid username (or email)password
needs to contain a matching passwordTried to put together a swagger definition for this:
swagger: "2.0"
info:
description: "Swagger definition for GW2Raidar's API"
version: "1.0.0"
title: "GW2Raidar API"
contact:
email: "merf@example.com"
host: "uat.gw2raidar.com"
basePath: "/api"
schemes:
- "https"
paths:
/upload.json:
post:
tags:
- "upload"
summary: "Upload a log"
description: ""
operationId: "upload"
consumes:
- "multipart/form-data"
parameters:
- name: "username"
in: "formData"
description: "User's name"
required: true
type: "string"
- name: "password"
in: "formData"
description: "User's password"
required: true
type: "string"
- name: "file"
in: "formData"
description: "Files"
required: false
type: "file"
responses:
200:
description: "successful operation"
But need to put more work into the arbitrary filename parameter (this is kind of an ugly pattern imo). Also doesn't seem to work.
Reason for swagger definition - can then generate ui at http://petstore.swagger.io/ or otherwise that could easily be used for testing.
You're right, it's a leftover from the time when I thought I'd be uploading multiple files in one request. That got scrapped quickly, but filename thing got forgotten. I'll rename it to something fixed like file
tomorrow.
EDIT: unless I forget :P
Tested this, it works. Can't use a swagger ui because we haven't set the allow origin headers to allow usage from other sites (which is understandable if we can get away with it, but at some point we may want to to enable client-side web app usage).
@merforga For testing, you can use the commandline option above, or I would suggest Postman https://www.getpostman.com/ . With postman you would set the method from GET to POST, set the url to https://uat.gw2raidar.com/api/upload.json , then switch to the body tab and add the username, password and file key/value pairs (there is a dropdown to the right of name to switch the value between text and file). Then click send.
Note that the command is changed, the the file
parameter is now fixed to file
:
curl -F "username=amadan" -F "password=notmypassword" -F "file=@/Users/amadan/Downloads/20170808-224359.evtc" https://uat.gw2raidar.com/api/upload.json
@amadanmath Plese confirm max file size limitation as discussed the other day. Also is there any limitations on API connectivity? eg simultaneous connections? Assume if someone were to want to upload multiple files, they'll create a new API connection for each file?
Functionality confirmed \o/
Also is there any limitations on API connectivity? eg simultaneous connections? Assume if someone were to want to upload multiple files, they'll create a new API connection for each file?
Identical to normal webpage upload. We have, I think, five (?) raidar processes running in Apache; that means five requests can be processed simultaneously. Any more than that should normally be held by Apache in a queue till a process gets freed up. Yes, one file per request.
Version 1.0.0 Released 24 October 2017
Create ap to automatically upload new logs directly to GW2R without having to drag drop. Just brain dump for now: