mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 00:33:30 +02:00
Implement APK uploads using the new storage system. Installation from URL still does not work, and dropping the file on the screen may not work either.
This commit is contained in:
40
res/app/components/stf/control/storage-service.js
Normal file
40
res/app/components/stf/control/storage-service.js
Normal file
@@ -0,0 +1,40 @@
|
||||
var Promise = require('bluebird')
|
||||
|
||||
module.exports = function StorageServiceFactory($http, $upload) {
|
||||
var service = {}
|
||||
|
||||
service.storeUrl = function(type, url) {
|
||||
return $http({
|
||||
url: '/api/v1/s/' + type + '/download'
|
||||
, method: 'POST'
|
||||
, data: {
|
||||
url: url
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
service.storeFile = function(type, files) {
|
||||
var resolver = Promise.defer()
|
||||
|
||||
$upload.upload({
|
||||
url: '/api/v1/s/' + type
|
||||
, method: 'POST'
|
||||
, file: files
|
||||
})
|
||||
.then(
|
||||
function(value) {
|
||||
resolver.resolve(value)
|
||||
}
|
||||
, function(err) {
|
||||
resolver.reject(err)
|
||||
}
|
||||
, function(progressEvent) {
|
||||
resolver.progress(progressEvent)
|
||||
}
|
||||
)
|
||||
|
||||
return resolver.promise
|
||||
}
|
||||
|
||||
return service
|
||||
}
|
||||
Reference in New Issue
Block a user