function registerToken(secrets,user,root)
{
- var url = "https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/" + user;
+ var url = "https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/"+user;
var xhr = oAuthRequest(url,secrets);
xhr.onreadystatechange = function() {
if(xhr.readyState===4) {
function getFiles(secrets,rootNode,root)
{
- var url = "https://one.ubuntu.com/api/file_storage/v1"
- +encodeURI(rootNode)+"/?include_children=true";
+ var url = encodeURI2("https://one.ubuntu.com/api/file_storage/v1"
+ +rootNode+"/?include_children=true");
//console.log("url: "+url);
var xhr = oAuthRequest(url,secrets);
xhr.onreadystatechange = function() {
root.onErr(xhr.status);
} else {
//console.log(xhr.responseText);
+ //console.log("");
+ //console.log(xhr.getAllResponseHeaders());
var resp = eval('('+xhr.responseText+')');
var nodes = resp.children;
root.onResp(nodes);
function renameFile(secrets,resourcePath,targetPath,root)
{
- var url = "https://one.ubuntu.com/api/file_storage/v1"+encodeURI(resourcePath);
- //console.log("url: "+url);
+ var url = encodeURI2("https://one.ubuntu.com/api/file_storage/v1"+resourcePath);
+ console.log("url: "+url);
//console.log("target: "+encodeURI(targetPath));
//console.log("target: "+targetPath);
var xhr = oAuthRequest(url,secrets,"PUT");
function stopPublishing(secrets,resourcePath,root)
{
- var url = "https://one.ubuntu.com/api/file_storage/v1"+encodeURI(resourcePath);
+ var url = encodeURI2("https://one.ubuntu.com/api/file_storage/v1"+resourcePath);
var xhr = oAuthRequest(url,secrets,"PUT");
xhr.setRequestHeader("Content-Type","application/json");
var body = '{"is_public":false}';
function startPublishing(secrets,resourcePath,root)
{
- var url = "https://one.ubuntu.com/api/file_storage/v1"+encodeURI(resourcePath);
+ var url = encodeURI2("https://one.ubuntu.com/api/file_storage/v1"+resourcePath);
var xhr = oAuthRequest(url,secrets,"PUT");
xhr.setRequestHeader("Content-Type","application/json");
var body = '{"is_public":true}';
function newFolder(secrets,resourcePath,root)
{
- var url = "https://one.ubuntu.com/api/file_storage/v1"+encodeURI(resourcePath);
- console.log("url: "+url);
+ var url = encodeURI2("https://one.ubuntu.com/api/file_storage/v1"+resourcePath);
+ //console.log("url: "+url);
var xhr = oAuthRequest(url,secrets,"PUT");
xhr.setRequestHeader("Content-Type","application/json");
var body = '{"kind": "directory"}';
- console.log("body: "+body);
+ //console.log("body: "+body);
xhr.onreadystatechange = function() {
if(xhr.readyState===4) {
if(xhr.status>=400||xhr.status===0) {
- console.log("status: "+xhr.status);
+ //console.log("status: "+xhr.status);
//console.log(xhr.responseText);
root.onErrNew(xhr.status);
} else {
function deleteFile(secrets,resourcePath,root,utils)
{
- var url = "https://one.ubuntu.com/api/file_storage/v1"+encodeURI(resourcePath);
- //console.log("url: "+url);
- var auth = oAuthHeader(url,secrets,"DELETE");
+ //var urlA = "https://one.ubuntu.com/api/file_storage/v1"+encodeURI(resourcePath);
+ var url = "https://one.ubuntu.com/api/file_storage/v1"+resourcePath;
+ var urlA = encodeURI2(url);
+
+ //console.log("u1.js:delete url="+url);
+ var auth = oAuthHeader(urlA,secrets,"DELETE");
utils.deleteFile(url,auth);
}
function getFileContentType(secrets,root,path)
{
//var url = "https://one.ubuntu.com/api/file_storage/v1"+encodeURI(path);
- var url = "https://files.one.ubuntu.com"+encodeURI(path);
+ var url = encodeURI2("https://files.one.ubuntu.com"+path);
//console.log("url: "+url);
var xhr = oAuthRequest(url,secrets,"GET","bytes=0-10");
xhr.onreadystatechange = function() {
function getFileContent(secrets,root,path,folder,size,utils)
{
//var url = "https://one.ubuntu.com/api/file_storage/v1"+encodeURI(path);
- var url = "https://files.one.ubuntu.com"+encodeURI(path);
+ var url = "https://files.one.ubuntu.com"+path;
+ var urlA = encodeURI2(url);
+
var filename = fixFilename(path);
var ffolder = fixFolder(folder);
//console.log("url: "+url);
//console.log("ffolder: "+ffolder);
- var auth = oAuthHeader(url,secrets,"GET");
+ var auth = oAuthHeader(urlA,secrets,"GET");
//console.log("auth: "+auth);
utils.downloadFile(ffolder,filename,url,size,auth);
}
function uploadFile(secrets,root,path,filename,folder,utils)
{
- //var url = "https://one.ubuntu.com/api/file_storage/v1"+encodeURI(path);
- //var url = "https://files.one.ubuntu.com"+path;
- var url = "https://files.one.ubuntu.com"+encodeURI(path);
- //console.log(url);
+ var url = "https://files.one.ubuntu.com"+path;
+ var urlA = encodeURI2(url);
+
+ //console.log("u1.js:uploadFile url=" + url);
+ //console.log("u1.js:uploadFile urAl=" + urlA);
+
var ffolder = fixFolder(folder);
- var auth = oAuthHeader(url,secrets,"PUT");
+ var auth = oAuthHeader(urlA,secrets,"PUT");
utils.uploadFile(ffolder,filename,url,auth);
}
-
+function encodeURI2(uri)
+{
+ var uri2 = encodeURI(uri);
+ uri2 = uri2.replace(/\%5B/g, "[");
+ uri2 = uri2.replace(/\%5D/g, "]");
+ return uri2;
+}