diff --git a/README.md b/README.md index e94afe7e..34e126fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@
- 🗂️Open-source file hosting solution, supporting Docker and serverless deployment, supporting multiple storage channels such as Telegram, Discord, Cloudflare R2, S3, Huggingface, etc., supporting WebDAV protocol and various RESTful APIs.
+🗂️Open-source file hosting solution, supporting Docker and serverless deployment, supporting multiple storage channels such as Telegram, Discord, Cloudflare R2, S3, Huggingface, WebDAV, etc., supporting WebDAV protocol and various RESTful APIs.
简体中文 | English | Official Website @@ -188,6 +188,25 @@ Provides detailed deployment documentation, feature docs, development plans, upd # 4. Tips +- **WebDAV storage channel**: Besides the built-in `/dav` WebDAV server, this project can also use a third-party WebDAV server as an upload storage channel. Configure a fixed channel with `WEBDAV_BASE_URL`; optional variables are `WEBDAV_USERNAME`, `WEBDAV_PASSWORD`, `WEBDAV_PUBLIC_URL`, `WEBDAV_HEADERS` (JSON object string), and `WEBDAV_CREATE_DIRECTORY=false`. Runtime channel config uses: + ```json + { + "webdav": { + "loadBalance": { "enabled": false }, + "channels": [{ + "name": "dav-main", + "type": "webdav", + "baseUrl": "https://dav.example.com/remote.php/dav/files/user/imgbed/", + "username": "user", + "password": "pass", + "publicUrl": "https://cdn.example.com/imgbed/", + "enabled": true + }] + } + } + ``` + The implementation uses Fetch/Web APIs only, so it is compatible with Cloudflare Pages Functions and Workers deployments. Basic authentication and no-auth WebDAV endpoints are supported; Digest-only providers are not supported. WebDAV chunked uploads are intentionally disabled, so large uploads must stay within your Cloudflare request body limits. + - Frontend is open source, see [MarSeventh/Sanyue-ImgHub](https://github.com/MarSeventh/Sanyue-ImgHub). - Desktop software is open source, see [MarSeventh/satellite](https://github.com/MarSeventh/satellite). diff --git a/README_zh.md b/README_zh.md index f6f73b6d..bff56a5c 100644 --- a/README_zh.md +++ b/README_zh.md @@ -1,6 +1,6 @@
- 🗂️开源文件托管解决方案,支持 Docker 和无服务器部署,支持 Telegram、Discord、Cloudflare R2、S3、Huggingface 等多种存储渠道,支持 WebDAV 协议和多种 RESTful API
+🗂️开源文件托管解决方案,支持 Docker 和无服务器部署,支持 Telegram、Discord、Cloudflare R2、S3、Huggingface、WebDAV 等多种存储渠道,支持 WebDAV 协议和多种 RESTful API
@@ -200,6 +200,25 @@ # 4. Tips +- **WebDAV 存储渠道**:除了内置 `/dav` WebDAV 服务外,本项目也可以把第三方 WebDAV 服务作为上传存储渠道使用。固定环境变量渠道可配置 `WEBDAV_BASE_URL`;可选变量包括 `WEBDAV_USERNAME`、`WEBDAV_PASSWORD`、`WEBDAV_PUBLIC_URL`、`WEBDAV_HEADERS`(JSON 对象字符串)和 `WEBDAV_CREATE_DIRECTORY=false`。运行时渠道配置结构如下: + ```json + { + "webdav": { + "loadBalance": { "enabled": false }, + "channels": [{ + "name": "dav-main", + "type": "webdav", + "baseUrl": "https://dav.example.com/remote.php/dav/files/user/imgbed/", + "username": "user", + "password": "pass", + "publicUrl": "https://cdn.example.com/imgbed/", + "enabled": true + }] + } + } + ``` + 实现仅使用 Fetch/Web API,因此可用于 Cloudflare Pages Functions 和 Workers 部署。支持 Basic 认证或无认证 WebDAV 端点;暂不支持仅 Digest 认证的服务。WebDAV 分片上传已明确禁用,大文件需在 Cloudflare 请求体限制范围内直接上传。 + - **前端开源**:参见[MarSeventh/Sanyue-ImgHub](https://github.com/MarSeventh/Sanyue-ImgHub)项目。 - **桌面端开源**:参见[MarSeventh/satellite](https://github.com/MarSeventh/satellite)项目。 diff --git a/deploy/worker/wrangler.toml b/deploy/worker/wrangler.toml index 61020138..d229bd12 100644 --- a/deploy/worker/wrangler.toml +++ b/deploy/worker/wrangler.toml @@ -23,6 +23,13 @@ not_found_handling = "single-page-application" [vars] # TG_BOT_TOKEN = "" # TG_CHAT_ID = "" +# Optional third-party WebDAV storage channel: +# WEBDAV_BASE_URL = "https://dav.example.com/remote.php/dav/files/user/imgbed/" +# WEBDAV_USERNAME = "" +# WEBDAV_PASSWORD = "" +# WEBDAV_PUBLIC_URL = "" +# WEBDAV_HEADERS = "{\"X-Example\":\"value\"}" +# WEBDAV_CREATE_DIRECTORY = "true" # [[d1_databases]] # binding = "img_d1" diff --git a/frontend-dist/js/577.2c9dad30.js b/frontend-dist/js/577.2c9dad30.js index a1b54472..39ac8d4c 100644 --- a/frontend-dist/js/577.2c9dad30.js +++ b/frontend-dist/js/577.2c9dad30.js @@ -1,2 +1,2 @@ -(self["webpackChunksanyue_imghub"]=self["webpackChunksanyue_imghub"]||[]).push([[577],{213:function(e,t,o){"use strict";o(85331),o(19104)},2893:function(e,t,o){"use strict";o(85331)},4885:function(e,t,o){"use strict";o(85331)},10456:function(e,t,o){"use strict";o(85331)},11393:function(e,t,o){o(16573),o(78100),o(77936),o(79577),o(41549),o(49797),o(49631),o(35623),o(64979),o(14603),o(47566),o(98721),function(t,o){e.exports=o()}(0,function(){return function(e){var t={};function o(s){if(t[s])return t[s].exports;var l=t[s]={i:s,l:!1,exports:{}};return e[s].call(l.exports,l,l.exports,o),l.l=!0,l.exports}return o.m=e,o.c=t,o.d=function(e,t,s){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(o.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)o.d(s,l,function(t){return e[t]}.bind(null,l));return s},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){"use strict";var s;function l(e){return["image/png","image/jpeg","image/gif"].some(t=>t===e)}o.r(t),o.d(t,"canvastoDataURL",function(){return a}),o.d(t,"canvastoFile",function(){return n}),o.d(t,"dataURLtoFile",function(){return d}),o.d(t,"dataURLtoImage",function(){return c}),o.d(t,"downloadFile",function(){return u}),o.d(t,"filetoDataURL",function(){return p}),o.d(t,"imagetoCanvas",function(){return m}),o.d(t,"urltoBlob",function(){return g}),o.d(t,"urltoImage",function(){return f}),o.d(t,"compress",function(){return b}),o.d(t,"compressAccurately",function(){return v}),o.d(t,"EImageType",function(){return s}),function(e){e.PNG="image/png",e.JPEG="image/jpeg",e.GIF="image/gif"}(s||(s={}));var i=function(e,t,o,s){return new(o||(o=Promise))(function(l,i){function a(e){try{r(s.next(e))}catch(e){i(e)}}function n(e){try{r(s.throw(e))}catch(e){i(e)}}function r(e){var t;e.done?l(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(a,n)}r((s=s.apply(e,t||[])).next())})};function a(e,t=.92,o=s.JPEG){return i(this,void 0,void 0,function*(){return l(o)||(o=s.JPEG),e.toDataURL(o,t)})}function n(e,t=.92,o=s.JPEG){return new Promise(s=>e.toBlob(e=>s(e),o,t))}var r=function(e,t,o,s){return new(o||(o=Promise))(function(l,i){function a(e){try{r(s.next(e))}catch(e){i(e)}}function n(e){try{r(s.throw(e))}catch(e){i(e)}}function r(e){var t;e.done?l(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(a,n)}r((s=s.apply(e,t||[])).next())})};function d(e,t){return r(this,void 0,void 0,function*(){const o=e.split(",");let s=o[0].match(/:(.*?);/)[1];const i=atob(o[1]);let a=i.length;const n=new Uint8Array(a);for(;a--;)n[a]=i.charCodeAt(a);return l(t)&&(s=t),new Blob([n],{type:s})})}function c(e){return new Promise((t,o)=>{const s=new Image;s.onload=()=>t(s),s.onerror=()=>o(new Error("dataURLtoImage(): dataURL is illegal")),s.src=e})}function u(e,t){const o=document.createElement("a");o.href=window.URL.createObjectURL(e),o.download=t||Date.now().toString(36),document.body.appendChild(o);const s=document.createEvent("MouseEvents");s.initEvent("click",!1,!1),o.dispatchEvent(s),document.body.removeChild(o)}function p(e){return new Promise(t=>{const o=new FileReader;o.onloadend=e=>t(e.target.result),o.readAsDataURL(e)})}var h=function(e,t,o,s){return new(o||(o=Promise))(function(l,i){function a(e){try{r(s.next(e))}catch(e){i(e)}}function n(e){try{r(s.throw(e))}catch(e){i(e)}}function r(e){var t;e.done?l(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(a,n)}r((s=s.apply(e,t||[])).next())})};function m(e,t={}){return h(this,void 0,void 0,function*(){const o=Object.assign({},t),s=document.createElement("canvas"),l=s.getContext("2d");let i,a;for(const e in o)Object.prototype.hasOwnProperty.call(o,e)&&(o[e]=Number(o[e]));if(o.scale){const t=o.scale>0&&o.scale<10?o.scale:1;a=e.width*t,i=e.height*t}else a=o.width||o.height*e.width/e.height||e.width,i=o.height||o.width*e.height/e.width||e.height;switch([5,6,7,8].some(e=>e===o.orientation)?(s.height=a,s.width=i):(s.height=i,s.width=a),o.orientation){case 3:l.rotate(180*Math.PI/180),l.drawImage(e,-s.width,-s.height,s.width,s.height);break;case 6:l.rotate(90*Math.PI/180),l.drawImage(e,0,-s.width,s.height,s.width);break;case 8:l.rotate(270*Math.PI/180),l.drawImage(e,-s.height,0,s.height,s.width);break;case 2:l.translate(s.width,0),l.scale(-1,1),l.drawImage(e,0,0,s.width,s.height);break;case 4:l.translate(s.width,0),l.scale(-1,1),l.rotate(180*Math.PI/180),l.drawImage(e,-s.width,-s.height,s.width,s.height);break;case 5:l.translate(s.width,0),l.scale(-1,1),l.rotate(90*Math.PI/180),l.drawImage(e,0,-s.width,s.height,s.width);break;case 7:l.translate(s.width,0),l.scale(-1,1),l.rotate(270*Math.PI/180),l.drawImage(e,-s.height,0,s.height,s.width);break;default:l.drawImage(e,0,0,s.width,s.height)}return s})}function g(e){return fetch(e).then(e=>e.blob())}function f(e){return new Promise((t,o)=>{const s=new Image;s.onload=()=>t(s),s.onerror=()=>o(new Error("urltoImage(): Image failed to load, please check the image URL")),s.src=e})}var y=function(e,t,o,s){return new(o||(o=Promise))(function(l,i){function a(e){try{r(s.next(e))}catch(e){i(e)}}function n(e){try{r(s.throw(e))}catch(e){i(e)}}function r(e){var t;e.done?l(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(a,n)}r((s=s.apply(e,t||[])).next())})};function b(e,t={}){return y(this,void 0,void 0,function*(){if(!(e instanceof Blob))throw new Error("compress(): First arg must be a Blob object or a File object.");if("object"!=typeof t&&(t=Object.assign({quality:t})),t.quality=Number(t.quality),Number.isNaN(t.quality))return e;const o=yield p(e);let i=o.split(",")[0].match(/:(.*?);/)[1],n=s.JPEG;l(t.type)&&(n=t.type,i=t.type);const r=yield c(o),u=yield m(r,Object.assign({},t)),h=yield a(u,t.quality,n),g=yield d(h,i);return g.size>e.size?e:g})}function v(e,t={}){return y(this,void 0,void 0,function*(){if(!(e instanceof Blob))throw new Error("compressAccurately(): First arg must be a Blob object or a File object.");if("object"!=typeof t&&(t=Object.assign({size:t})),t.size=Number(t.size),Number.isNaN(t.size))return e;if(1024*t.size>e.size)return e;t.accuracy=Number(t.accuracy),(!t.accuracy||t.accuracy<.8||t.accuracy>.99)&&(t.accuracy=.95);const o=t.size*(2-t.accuracy)*1024,i=1024*t.size,n=t.size*t.accuracy*1024,r=yield p(e);let u=r.split(",")[0].match(/:(.*?);/)[1],h=s.JPEG;l(t.type)&&(h=t.type,u=t.type);const g=yield c(r),f=yield m(g,Object.assign({},t));let y,b=.5;const v=[null,null];for(let e=1;e<=7;e++){y=yield a(f,b,h);const t=.75*y.length;if(7===e){(o