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() {
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);
+ 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");
function deleteFile(secrets,resourcePath,root,utils)
{
- var urlA = "https://one.ubuntu.com/api/file_storage/v1"+encodeURI(resourcePath);
+ //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"+path;
- var urlA = "https://files.one.ubuntu.com"+encodeURI(path);
+ var urlA = encodeURI2(url);
var filename = fixFilename(path);
var ffolder = fixFolder(folder);
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"+path;
- var urlA = "https://files.one.ubuntu.com"+encodeURI(path);
+ var urlA = encodeURI2(url);
- //console.log("u1.js:uploadFile path=" + path);
//console.log("u1.js:uploadFile url=" + url);
+ //console.log("u1.js:uploadFile urAl=" + urlA);
var ffolder = fixFolder(folder);
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;
+}