mirror of
https://github.com/openstf/stf
synced 2025-10-05 10:39:25 +02:00
APKs can now be drag & dropped to the device screen, which will install the application. Still lacking UI, and the app doesn't get launched.
This commit is contained in:
parent
5771507fc9
commit
dfe3d97de3
12 changed files with 280 additions and 8 deletions
71
lib/roles/storage/temp.js
Normal file
71
lib/roles/storage/temp.js
Normal file
|
@ -0,0 +1,71 @@
|
|||
var http = require('http')
|
||||
var util = require('util')
|
||||
|
||||
var express = require('express')
|
||||
var formidable = require('formidable')
|
||||
var Promise = require('bluebird')
|
||||
|
||||
var logger = require('../../util/logger')
|
||||
var Storage = require('../../util/storage')
|
||||
|
||||
module.exports = function(options) {
|
||||
var log = logger.createLogger('storage-temp')
|
||||
, app = express()
|
||||
, server = http.createServer(app)
|
||||
, storage = new Storage()
|
||||
|
||||
app.set('strict routing', true)
|
||||
app.set('case sensitive routing', true)
|
||||
app.set('trust proxy', true)
|
||||
|
||||
app.use(express.json())
|
||||
app.use(express.urlencoded())
|
||||
|
||||
storage.on('timeout', function(id) {
|
||||
log.info('Cleaning up inactive resource "%s"', id)
|
||||
})
|
||||
|
||||
app.post('/api/v1/resources', function(req, res) {
|
||||
var form = Promise.promisifyAll(new formidable.IncomingForm())
|
||||
form.parseAsync(req)
|
||||
.spread(function(fields, files) {
|
||||
if (files.file) {
|
||||
var id = storage.store(files.file)
|
||||
res.json(201, {
|
||||
success: true
|
||||
, url: util.format(
|
||||
'http://%s:%s/api/v1/resources/%s'
|
||||
, options.publicIp
|
||||
, options.port
|
||||
, id
|
||||
)
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.json(400, {
|
||||
success: false
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.error('Failed to save resource: ', err.stack)
|
||||
res.json(500, {
|
||||
success: false
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
app.get('/api/v1/resources/:id', function(req, res) {
|
||||
var file = storage.retrieve(req.params.id)
|
||||
if (file) {
|
||||
res.set('Content-Type', file.type)
|
||||
res.sendfile(file.path)
|
||||
}
|
||||
else {
|
||||
res.send(404)
|
||||
}
|
||||
})
|
||||
|
||||
server.listen(options.port)
|
||||
log.info('Listening on port %d', options.port)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue