您的足迹:首页 > 我的代码 >autojs-坚果云操作(创建,删除,下载,上传)

autojs-坚果云操作(创建,删除,下载,上传)

直接上代码。。


var url = "http://dav.jianguoyun.com/dav/";
var name = "";//坚果云账号
var pass = "";//获取方式 https://writer.drakeet.com/backups
var code = base64(name + ":" + pass);

function 创建目录(name) {
    //用于创建目录
    //vat name = "Writer.txt;
    var res = http.request(url + name, {
        method: "MKCOL",
        headers: {
            "Authorization": "Basic " + code,
            "Connection": "Keep-Alive",
            "Accept-Encoding": "gzip",
            "User-Agent": "okhttp/3.12.1"
        },

    });
    log(res["statusCode"]);
}

function 删除(path) {
    //删除一个文件
    //var path = "Put/Writer.txt";
    var res = http.request(url + path, {
        method: "DELETE",
        headers: {
            "Authorization": "Basic " + code,
            "Connection": "Keep-Alive",
            "Accept-Encoding": "gzip",
            "User-Agent": "okhttp/3.12.1"
        }
    });
    log(res.body.string());
}

function 获取(path) {
    //获取一个资源文件
    //var url = "Put/Writer.txt";
    var res = http.get(url + path, {
        headers: {
            "Authorization": "Basic " + code,
            "Content-Type": "text/plain;charset=UTF-8",
            "Connection": "Keep-Alive",
            "Accept-Encoding": "gzip",
            "User-Agent": "okhttp/3.12.1"
        }
    });
    log(res.body.string());
}

function 上传(path, str) {
    //上传文件
    //var path = "Put/Writer.txt";
    var res = http.request(url, {
        method: "PUT",
        headers: {
            "Authorization": "Basic " + code,
            "Content-Type": "text/plain;charset=UTF-8",
            "Connection": "Keep-Alive",
            "Accept-Encoding": "gzip",
            "User-Agent": "okhttp/3.12.1"
        },
        //body: "Javascript 面向对象编程—继承和封装"
        body: str
    });
    log(res.body.string());
}

function base64(str) {
    return java.lang.String(android.util.Base64.encode(java.lang.String(str).getBytes(), 2));
}


------------------------


本博客所有文章如无特别注明均为原创。作者:恶猫复制或转载请以超链接形式注明转自 恶猫的博客
原文地址《autojs-坚果云操作(创建,删除,下载,上传)

相关推荐

分享本文至:

发表评论

路人甲 表情
看不清楚?点图切换 Ctrl+Enter快速提交

网友评论(0)

恶猫的博客 -记录自己日常,代码,美图,电影,音乐,新闻,只是个人博客而已

浙ICP备15011757号-4 网站地图 联系我