Git Product home page Git Product logo

act-scio-api's Introduction

scio-api

Web API for submitting and retrieving documents from Scio

Build

$ lein deps
$ lein uberjar

Usage

$ java -jar target/scio-api-0.1.0-SNAPSHOT-standalone.jar -h
Usage: java -jar scio-api-VERSION.jar [OPTION...]

-c, --config=CONFIGFILE      Specify ini location
-h, --help                   print this text

You can also override the default location of the .ini file by exporting the SCIOAPIINI environment variable.

report bugs to [email protected]

examples

$ java -jar scio-api-0.1.0-standalone.jar -c /opt/scio/scio.ini
$ SCIOAPIINI=/opt/scio/scio.ini java -jar scio-api-0.1.0-standalone.jar

Configuration

Consider sharing the .ini file between scio and scio-api

[beanstalk]
queue = submit
host = localhost
port = 11300

[elasticsearch]
host = http://localhost:9201 http://localhost:9202

[storage]
storagedir = /tmp

[api]
port = 3000

[beanstalk]

queue: This is the beanstalk tube shared by scio-api and scio. This is where scio retrieves the filenames to scrape for indicators.

host: The hostname of the beanstalkd service

port: The ports running the beanstalkd service

[elasticsearch]

host: A list of hosts separated by space. This is the list of coordinators in the case of a cluster.

[storagedir]

storagedir: The directory where the submitted documents are stored. This can be the same place as scio stores the documents. Important: scio must be able to read the files in this directory

[api]

port: The port the web API will be listening on.

Tests using curl to verify everything works

Submitting data

The Content-Type MUST be "application/json" The data must be a json map with the keys "content" containing the file content as base64 and "filename" containing the basename of the file.

$ curl -H "Content-Type: application/json" -X POST --data '{"content": "MTI3LjAuMC4xCg==", "filename": "testfile.txt"}' http://localhost:3000/submit
{"error":null,"filename":"/tmp/testfile.txt","bytes":10}⏎
$

Downloading data

Default behavior (no format parameter)

$ curl 'http://localhost:3000/download?id=ee128a27e0f98844713ea51f5ca339803033b35f4df2d764f9c8eb40856a38c3'
Test og tast
$

With format=json

$ curl 'http://localhost:3000/download?id=ee128a27e0f98844713ea51f5ca339803033b35f4df2d764f9c8eb40856a38c3&format=json'
{"error":null,"bytes":13,"filename":"Infocon_green.html","content":"VGVzdCBvZyB0YXN0Cg==","encoding":"base64"}⏎                                                         ~
$

License

ISC License

Copyright (c) 2016-2018, mnemonic as [email protected]

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.