GW2Raidar / gw2raidar

A log parsing website for Guild Wars 2 combat logs
http://www.gw2raidar.com
GNU General Public License v3.0
20 stars 14 forks source link

Create Desktop Uploader Ap #157

Closed merforga closed 6 years ago

merforga commented 6 years ago

Create ap to automatically upload new logs directly to GW2R without having to drag drop. Just brain dump for now:

  1. API key per user to connect and authenticate with server (shown on account page)
  2. Date selection (ie upload all files from this date onwards)
  3. List of files uploaded with boss name
  4. Omit non-supported bosses
merforga commented 6 years ago

Related to #136

amadanmath commented 6 years ago

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
immortius commented 6 years ago

Tried 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.

amadanmath commented 6 years ago

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

immortius commented 6 years ago

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.

Example

amadanmath commented 6 years ago

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
merforga commented 6 years ago

@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?

merforga commented 6 years ago

Functionality confirmed \o/

amadanmath commented 6 years ago

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.

merforga commented 6 years ago

Version 1.0.0 Released 24 October 2017