美文网首页
自定义oneDrive接口分享

自定义oneDrive接口分享

作者: kevin5979 | 来源:发表于2020-12-03 10:09 被阅读0次

    开发资料

    postman共享接口地址

    https://www.getpostman.com/collections/e817899d47c4b2d09132

    如果有能力自己开发后端,官方开发文档给你贴出来,整就完事!!

    https://docs.microsoft.com/zh-cn/onedrive/developer/rest-api/getting-started/?view=odsp-graph-online



    postman安装

    将api导入postman

    本地导入链接 https://www.getpostman.com/collections/e817899d47c4b2d09132


    请求根路径

    • http://localhost:3001/api
    1. 设置登录重定向
    // 登录前的必要操作
    POST   /redirect
    data: {"key":"redirect_uri","value":"http://loccalhost2020?login=true","type":"text"}
    
    1. 登录
    // 直接打开链接即可
    GET   https://login.microsoftonline.com/common/oauth2/v2.0/authorize
    "params": [{
                  "key": "client_id",
                  "value": "bcb8f905-d047-4cf1-a3e2-5f98aab8b8ac"
                },
                {
                  "key": "scope",
                  "value": "offline_access Files.Read Files.Read.All Files.ReadWrite Files.ReadWrite.All Files.ReadWrite.AppFolder Sites.Read.All Sites.ReadWrite.All"
                },
                {
                  "key": "response_type",
                  "value": "code"
                },
                {
                  "key": "redirect_uri",
                  "value": "http://localhost:3001/api"
                }]
    
    1. 退出登录
    // 退出后,token失效
    DELETE    /
    
    1. 获取根文件/文件夹
    // 包括特殊文件夹和自建文件/文件夹
    GET    /getRootItem
    
    1. 根据id获取子代信息
    GET    /getItems
    params: {"key":"itemId","value":"7F7BB3930A6A42A7!104","type":"text"}
    
    1. 获取token
    GET    /token
    
    1. 获取item的详细信息
    GET    /getItem
    params: {"key":"itemId","value":"7F7BB3930A6A42A7!104","type":"text"}
    
    1. 搜索关键词
    // 搜索root, query 关键词: 多个字段匹配,包括文件名,元数据和文件内容
    GET    /search
    params: {"key":"keyword","value":"haha","type":"text"}
    
    1. 新建文件夹
    // itemId表示上级文件夹id
    GET    /newly
    params: [
    {"key":"itemId","value":"7F7BB3930A6A42A7!104","type":"text"},
    {"key":"name","value":"haha","type":"text"},
    ]
    
    1. 删除文件/文件夹
    DELETE    /remove
    params: {"key":"itemId","value":"7F7BB3930A6A42A7!104","type":"text"}
    
    1. 重命名文件/文件夹
    GET    /modify
    params: [
    {"key":"itemId","value":"7F7BB3930A6A42A7!104","type":"text"},
    {"key":"name","value":"haha","type":"text"},
    ]
    
    1. 复制文件/文件夹
    GET    /modify/copy
    params: [
    {"key":"itemId","value":"7F7BB3930A6A42A7!104","type":"text"},
    {"key":"targetId","value":"7F7BB3930A6A42A7!104","type":"text"},
    {"key":"name","value":"haha","type":"text"},
    ]
    
    1. 移动文件/文件夹
    GET   /modify/move
    params: [
    {"key":"itemId","value":"7F7BB3930A6A42A7!104","type":"text"},
    {"key":"targetId","value":"7F7BB3930A6A42A7!104","type":"text"},
    {"key":"name","value":"haha","type":"text"},
    ]
    
    1. 下载文件
    GET    /download
    params: {"key":"itemId","value":"7F7BB3930A6A42A7!104","type":"text"}
    
    1. 按格式下载文件
    // format 参考文档
    // https://docs.microsoft.com/zh-cn/onedrive/developer/rest-api/api/driveitem_get_content_format?view=odsp-graph-online
    GET    /download
    params: [
    {"key":"itemId","value":"7F7BB3930A6A42A7!104","type":"text"},
    {"key":"format","value":"html","type":"text"}
    ]
    
    1. 上载文件
    POST    /upload
    data: [
    {"key":"parentId","value":"7F7BB3930A6A42A7!678","type":"text"},
    {"key":"filename","value":"test","type":"text"},
    {"key":"content","value":"二进制流","type":"text"}
    ]
    
    1. 分享文件(创建链接)
    GET    /share
    params: {"key":"itemId","value":"7F7BB3930A6A42A7!104","type":"text"}
    
    1. 按名字获取特殊文件夹
    // 特殊文件夹type参考文档 
    // https://docs.microsoft.com/zh-cn/onedrive/developer/rest-api/api/drive_get_specialfolder?view=odsp-graph-online
    GET    /getSpecial
    params: {"key":"type","value":"apps","type":"text"}
    
    1. 列出最近文件
    GET    /getRecent
    
    1. 获取缩略图
    GET    /getThumbnails
    params: {"key":"itemId","value":"7F7BB3930A6A42A7!678","type":"text"}
    
    以上可能存在错误,具体以postman的数据为准

    END

    相关文章

      网友评论

          本文标题:自定义oneDrive接口分享

          本文链接:https://www.haomeiwen.com/subject/zkiuwktx.html