DRIVE API
DRIVE API is used by third party web applications to access users resources.
An application key name is required in conjunction with the open authorization web application in order to gain a valid access token.
The application key will give access to folders stored in "Applications" root folder.
There are two base folders that may be preset for each app key:
- Applications/<basename> - used to store application files
- Applications/webroot/<webpath> - used to store public application files (Applications/webroot/ is the start point for resources that can be accessed via a web url address)
READ
folderdata
URL: https://q-ube.com:3200/sfd/folderdata
Method: POST
Headers: {Authorization: Bearer <token>}
Data: {
appkey:<appkey>,
id:<foldername || folderpath>,
ft:<web || any>
}
appkey - the application key name
id - foldername that will be verified or a folder path
ft - if it is "web" the requested folder data is located under "Applications/webroot/<webkeypath>" path.
OK result is a JSON structure that describe the folder status.
Error is a NOT found message.
folderfiles
URL: https://q-ube.com:3200/sfd/folderfiles
Method: POST
Headers: {Authorization: Bearer <token>}
Data: {
appkey:<appkey>,
id:<foldername || folderpath>,
ft:<web || any>
}
appkey - the application key name
id - foldername or a folder path - the files list folder
ft - if it is "web" the requested folder data is located under "Applications/webroot/<webkeypath>" path.
OK result is a JSON structure of the files list.
Error is a NOT found message.
getfiletp - Get one file
URL: https://q-ube.com:3200/sfd/getfiletp
Method: POST
Headers: {Authorization: Bearer <token>}
Data: {
appkey:<appkey>,
id:<filepath || folder / file name>,
ft:<web || any>
}
appkey - the application key name
id - filename or a file path
ft - if it is "web" the requested folder data is located under "Applications/webroot/<webkeypath>" path.
OK result is a JSON structure of the files list.
Error is a NOT found message.
WRITE
createfolder - create one folder
URL: https://q-ube.com:3200/sfd/createfolder
Method: POST
Headers: {Authorization: Bearer <token>}
Data: {
appkey:<appkey>,
id:<folder path>,
folder: <folder name>,
ft:<web || any>
}
appkey - the application key name
id - folder path, the parent folder path (Ex: folder1/folder2)
folder - folder name (use only alfanumeric and NO spaces, CAN NOT be a path)
ft - if it is "web" the requested folder data is located under "Applications/webroot/<webkeypath>" path.
OK result is a JSON.
Error - information about the error (JSON).
upload - file upload
It is a file upload form-post.
URL: https://q-ube.com:3200/filetp/s3enc/<folder id>?token=<token>&appkey=<appkey>&ft=<ftype>
Data: {s3enc: <file>};
token - authorization token
appkey - your application key
ft - folder type (save into application folder or into a declared public folder path)
ft=web for web public folder
Sample for AngularJS:
- use Upload services ( ng-file-upload.js || ng-file-upload.min.js )
load next scripts before you load your controller js files:
<script src="https://drive.webdo.com/dst/jss/angular-file-model.js"></script>
<script src="https://drive.webdo.com/dst/jss/ng-file-upload.min.js"></script>
<script src="https://drive.webdo.com/dst/jss/ng-file-upload-shim.min.js"></script>
The file upload function is attached to the file object.
//....
file.upload = Upload.upload({url: url,
data: data
});
file.upload.then(function (response) {
next(false,response,ext,file.size);
}, function (error){
next(error,false)},
function (evt) {
$scope.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
}
);
//....
File will be write over if exist.
savefile - upload a file from memory
- create the file as a new blob and use file upload to write the file ( check "upload" )
Angular samples:
// Text
var strtext = JSON.stringify({xname:"webcentral.eu"});
var file = new Blob([strtext,{type:"application/json"});
file.name = "myfile.json";
savefile(file,folder,function(error,response){
// code
});
// Files - create
// create a new blob, requires an array buffer;
var file = new Blob([Buffer], {type: file.type});
file.name = "myfile.ext";
savefile(file,folder,function(error,response){
//code
});
renamefile
DELETE
deletefile
deletefolder