Code Monkey home page Code Monkey logo

onedrive-index-cloudflare-worker's Introduction

DEPRECATED: Please use https://github.com/spencerwooo/onedrive-cf-index instead

中文 | English

OneDrive Index ( Cloudflare Worker )

🌈 演示地址

storage.idx0.workers.dev

咋用

  1. 去这里新建一个 APP https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade redirect_uri 设置成 https://heymind.github.io/tools/microsoft-graph-api-auth

  2. Certificates & secrets 面板创建一个新的 secret

  3. API permissions 面板, 添加以下权限 offline_access, Files.Read, Files.Read.All。(此权限可以在Microsoft Graph中找到)

  4. 使用这个工具 microsoft-graph-api-auth 获取 refresh_token 参数。

  5. Cloudflare Worker 管理页面创建一个新的 Worker ,粘贴 index.js 中的代码并替换相关参数。

*6. 访问密码设置(默认关闭):

const AUTH_ENABLED = true
const NAME = "admin"
const PASS = "password"

🔥 新特性 V1.1

⏬ 中转下载

利用 Cloudflare 服务器中转 OneDrive 中文件的下载,以提高**大陆的下载体验。已知问题,无法显示下载进度。

在配置中开启 proxyDownload 功能,在文件直链路径后面加 ?proxied 即可开启,例如: https://storage.idx0.workers.dev/Other/zero_file?proxied

( Cloudflare 的速度也挺随缘的... )

☁️ 缓存功能

利用 Cloudflare CDN 来缓存 OneDrive 中文件,目前有两种缓存模式:

  • 整个文件缓存: 文件会先完整传输到 Cloudflare 的服务器后再返回给客户端。文件太大可能超过 Cloudflare Worker 限制的单次请求运行时间。
  • chunk 缓存: 流式传输与缓存,无法正确显示 Content-Length

在配置中开启 cache 功能,可以配置两种缓存模式的选择以及启用缓存的路径地址。

⏫ 小文件上传

可以利用这个工具直接上传小文件到 OneDrive 上 ( 小于 4MB ,OneDrive API 的限制,比这个大就得创建 upload session 反正很麻烦 )

在配置中开启 upload 功能,并设置一个密钥 key ( 防止游客上传文件 )。

比如:

POST https://storage.idx0.workers.dev/Images/?upload=<filename>&key=<key>

注意:开启该功能需要 Files.ReadWrite 权限

🖼️ 缩略图

对于图片文件,可以直接获取不同尺寸的缩略图。 比如:https://storage.idx0.workers.dev/Images/public-md-image-20191010113652775.png?thumbnail=mediumSquare

可用的取值参见:https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_thumbnails?view=odsp-graph-online#size-options

👍 没错,这就是个好用的博客图床!

同时开启缓存功能小文件上传功能后,这就是个自建图床。 配合缩略图功能,亦可提升博客页面在不同场景下的加载体验。

例如 https://blog.idx0.dev 在首页文章列表配图使使用了 large 尺寸的缩略图,在侧栏文章列表中使用了 smallSquare 尺寸的缩略图。

onedrive-index-cloudflare-worker's People

Contributors

davidtai780 avatar heymind avatar reycn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onedrive-index-cloudflare-worker's Issues

没有api权限的教育版5T帐号,是不是无法用这个啊?

如题,无意中发现了这个程序,用普通个人帐号试了一下完全没问题。

用教育版的,同样的方式怎么都提示没有那3个权限的借口,
但看接口的说明不是强制需要管理员同意的阿?

想问问开发者我这种情况能用吗?还是有其他办法绕过,只用user。read 实现不了嘛?

开发者e5账号 部署后报错

{"code":"itemNotFound","message":"The resource could not be found.","innerError":{"request-id":"1b109a25-4b1e-41ab-a394-19eba6d94502","date":"2020-02-23T04:59:17"}}

建议录制部署gif

工具的操作中,第三块的'code'不是很理解是什么..建议录制一个部署gif...
另外,刚刚访问示例站挂了:

{"code":"InvalidAuthenticationToken","message":"CompactToken validation failed with reason code: 80049228.","innerError":{"request-id":"c64adf17-58e7-491e-9c39-cb944c64366f","date":"2020-01-31T04:17:17"}}  

求助

我想要向站点上传,服务器端已配置完成,允许上传功能,但是我不知道代码该怎么写。
我使用python requests库,希望大神们伸出援手,帮我写一个完整的示例代码。谢谢!

Get 'invalid_request' error message while trying to obtain an access token

Failed to fetch an access token in step 4 of the Microsoft Graph API Auth, as it returned the following error message:

{"error":"invalid_request",
"error_description":"AADSTS90023: Cross-origin token redemption is permitted only for the 'Single-Page Application' client-type.\r\n
Trace ID: 453b0c3d-1fe6-4b38-ab32-b28f87451a01\r\n
Correlation ID: b822bb6f-d14b-48ec-bb56-c8e0b123935c\r\n
Timestamp: 2020-08-09 07:49:42Z",
"error_codes":[90023],
"timestamp":"2020-08-09 07:49:42Z",
"trace_id":"453b0c3d-1fe6-4b38-ab32-b28f87451a01",
"correlation_id":"b822bb6f-d14b-48ec-bb56-c8e0b123935c"}

Cache 有问题

只要打开cache ,下载大于100M的文件就会报错。无论缓存标准是多少。

access token经常失效

当使用量大时

经常会出现access token过期失效的现象,原因尚不确定,清空缓存无效,必须要手动获取新的refresh token,非常麻烦,影响使用。如果项目还在维护,望修复!

Heorku Deployable App

Hey, I don't know chinese but the app you made there is something I have been searching for.
Could you make a heroku deployable app, like a one click deploy to heroku thing? Like this [https://github.com/maple3142/heroku-aria2c]
I don't know anything about coding and stuff, I made my own heroky deployable aria2 leecher using the guide above and I hope you could make a one click heroku deployable index with token info etc for easy access and hopefully in english.

最后get_token

"error":"invalid_grant","error_description":"AADSTS9002313: Invalid request. Request is malformed or invalid
个人版和教育版都这样报错

adding cors for ?proxied content

Hello,

any idea how to enable "Access-Control-Allow-Origin": '*', for ?proxied content ?! i've add "Access-Control-Allow-Origin": '*', almost everywhere but still when i try to access content from url?proxied it still cannot access it from another website

async function proxiedDownload(downloadUrl) {
    console.info(`ProxyDownload -> ${downloadUrl}`);
    const remoteResp = await fetch(downloadUrl);
    let option = {
        status: 200, 
        headers: {
        "Access-Control-Allow-Origin": '*',
        }
    };
    let {
        readable,
        writable
    } = new TransformStream();
    remoteResp.body.pipeTo(writable);
    return new Response(readable, remoteResp, option);
}

is not working... help?

Thanks

文件下载有问题

有一些超过100MB的文件在下载的时候cloudflare会报错,错误代码1101
请问这个怎么解决?

Worker无法显示

正确填写完参数后出现{"code":"itemNotFound","message":"Item does not exist","innerError":{"request-id":"80847114-1c29-4425-88d3-ee7f71b13f00","date":"2020-03-08T21:14:01"}}

README doesn't always load in Chrome (Chromium Browsers)

发现 script.js 里面获取 README.md 的时候,经常会因为 uBlock Origin 或者 IDM Integration 等插件冲突(特指 Chrome 以及同家族浏览器,比如 Edge Chromium),导致 302 请求转发之后浏览器并没有拿到 README.md 里面的内容,进而导致无法渲染当前页面的 README.md

问题复现

步骤

  • 开启 uBlock Origin 等插件;
  • 在 Chrome / Edge Chromium 中打开演示地址:https://storage.idx0.workers.dev
  • 结果:无法渲染 README.md
  • 打开在 Chrome DevTools「网络」一栏重新加载,观察请求;

结果

请求被 Stall,很久都无法加载。

image

image

消融实验

Firefox 正常模式(开启 uBlock Origin 等插件)

image

正常加载,可以渲染 README.md

Chrome / Edge Chromium 隐身模式(即关闭 uBlock Origin 等插件)

image

正常加载,可以渲染 README.md

就很懵……

主题建议

不得不说,现在oneindex的界面太丑了,希望加一个上传按钮,而且上传不限大小。其他的,,我希望文件名前的那个图片不要都是绿色的呀!

建议

希望增加评论的插件,而且最好能在页面底部加入“上传”按钮,并支持大文件上传。

不支持个人账户吗

Authorize for code这一步,Client ID等没问题
点击"Authorize"登陆微软账号提示“无法使用个人帐户在此登录,请改用工作或学校帐户。”

无法返回code

office365订阅类型:msdn e3
正常使用rclone,已开放所需api权限
使用工具 microsoft-graph-api-auth无法返回第五步需要的code

token 不能自动刷新

token不能自动刷新,经常过两天就要手动重新获取token,非常麻烦,希望改进。

加密无法正常使用

由于本人疏忽,粘贴代码时遗漏主逻辑,导致当前版本无法正常使用加密功能。

故开 Issue 提醒各位,已经提交正确版本的 PR [Urgent] 修复访问密码未生效问题

为避免不必要的消极影响,请 owner 合并最新 PR 或回滚为无加密版本,并之后关闭此 issue。

深表歉意。

根目录无法使用

"message":"Resource not found for the segment 'root:'
还有使用microsoft-graph-api-auth工具的
offline_access,Files.Read,Files.Read.All应将逗号改为空格才会生效

可以设置默认走CF 代理吗

如题,可以设置默认走CF代理吗
如果不能,建议添加这个功能,或者在界面添加直链下载和走CF代理下载的选项
不然感觉要走代理的话要改链接比较麻烦

Access Token has Expired

I've successfully hosted the index on my cloudflare worker. But after sometime I'm getting this error when I'm trying to open the Index -

"{"code":"InvalidAuthenticationToken","message":"Access token has expired.","innerError":{"date":"2020-06-29T08:49:21","request-id":"597dcfcd-fe73-4e92-9af7-134ca46da70e"}}"

Anyway to fix it?

第三步获取token失败

{
	"error": "invalid_client",
	"error_description": "AADSTS50011: The reply url specified in the request does not match the reply urls configured for the application: 'a604eca4-fd91-44ce-ae3d-e7292d30522f'.\r\nTrace ID: d4d2121c-0271-449e-b8ac-2717a8ab4c01\r\nCorrelation ID: 569f91a8-2a9d-456f-8a7c-e8e531df9503\r\nTimestamp: 2019-11-13 03:29:52Z",
	"error_codes": [50011],
	"timestamp": "2019-11-13 03:29:52Z",
	"trace_id": "d4d2121c-0271-449e-b8ac-2717a8ab4c01",
	"correlation_id": "569f91a8-2a9d-456f-8a7c-e8e531df9503",
	"error_uri": "https://login.microsoftonline.com/error?code=50011"
}

取消基本认证

我希望我的网站是公开的,不需要任何密码就可以访问.

变数清空后就没有作用了......

const NAME = ""
const PASS = ""

我对机器翻译表示歉意.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.