Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义域名后面的路径能不能自定义裁剪一下 #45

Open
zhiyue opened this issue Nov 19, 2024 · 13 comments
Open

自定义域名后面的路径能不能自定义裁剪一下 #45

zhiyue opened this issue Nov 19, 2024 · 13 comments
Assignees

Comments

@zhiyue
Copy link

zhiyue commented Nov 19, 2024

比如填入的路径是:images/uploads/{year}{month}/original/{md5}.{extName}
希望能得到的是: image.domain.com/{year}{month}/original/{md5}.{extName}

@wayjam
Copy link
Owner

wayjam commented Nov 20, 2024

这个需求的原因是否是,这些图片对外提供访问的时候会有一定的 rewrite?所以希望这里上传后返回的路径跟上传的路径不一致。

如果是的会我觉得可以做一个 outputUrlRewriteRegexp 的配置,配置入正则Pattern,输出的时候用这个正则处理一下路径可能更灵活一些。这样可以给输出路径移除或者增加都行。

@fscarmen
Copy link

fscarmen commented Dec 4, 2024

是的,我也有这个需求,因为桶设置为private,我把账户PAT和路径都放在 worker rewrite 了。这样在更安全的前提下也方便分享使用。

比如填入的路径是:https://cluster-test-1.s3.us-east-005.backblazeb2.com/files/20241204215433284.webp
希望能得到的是: https://custom.domain.com/20241204215433284.webp (现在是 https://cluster-test-1.s3.us-east-005.backblazeb2.com/files/20241204215433284.webp)

这个 custom.domain.com 是我在 worker 里重写 url (包括路径) 并自定义的域名。

所以希望能在添加配置里,有一个能自定义域名的选项,支持占位符 {path} {fileName} {extName} ,如上面的例,可以填入

https://custom.domain.com/{fileName}.{extName}

@wayjam wayjam self-assigned this Dec 7, 2024
@wayjam
Copy link
Owner

wayjam commented Dec 8, 2024

Released v1.4.0-beta.1 Latest

重写了输出路径的格式化方法。请查看 README.mdoutputURLPattern,支持了更多的 payload 和正则替换,更加灵活,理论上可以适应所有场景。

@fscarmen
Copy link

fscarmen commented Dec 8, 2024

image

我多次升级,之后重启picgo,看版本仍然是 1.3.9 呢,应该如何处理?我又不太敢卸载后重新安装,怕所有的配置要重新设置,很麻烦。

@wayjam
Copy link
Owner

wayjam commented Dec 9, 2024

@fscarmen 新版引入了 mime 的 esm 版,GUI版PIcGO加载不出来了,在 1.4.0-beta.2 修复了。

CLI版升级方式:

picgo add picgo-plugin-s3@1.4.0-beta.2

GUI版升级方式:

界面 npm api 可能有 cache,没有搜出来 1.4.0 版则可以先进去以下目录,然后使用 npm install picgo-plugin-s3@1.4.0-beta.2

Windows: %APPDATA%\picgo\data.json
Linux: $XDG_CONFIG_HOME/picgo/data.json or ~/.config/picgo/data.json
macOS: ~/Library/Application\ Support/picgo/data.json

@fscarmen
Copy link

fscarmen commented Dec 9, 2024

谢谢啊,可以了。我以为自己pc的问题,搞了一整天都不行。

@fscarmen
Copy link

fscarmen commented Dec 9, 2024

Released v1.4.0-beta.1 Latest

重写了输出路径的格式化方法。请查看 README.mdoutputURLPattern,支持了更多的 payload 和正则替换,更加灵活,理论上可以适应所有场景。

这个 outputURLPattern 太好用了,我是 https://<worker 自定义域名>/{fullName}

@fscarmen
Copy link

fscarmen commented Dec 10, 2024

@fscarmen 新版引入了 mime 的 esm 版,GUI版PIcGO加载不出来了,在 1.4.0-beta.2 修复了。

CLI版升级方式:

picgo add picgo-plugin-s3@1.4.0-beta.2

GUI版升级方式:

界面 npm api 可能有 cache,没有搜出来 1.4.0 版则可以先进去以下目录,然后使用 npm install picgo-plugin-s3@1.4.0-beta.2

Windows: %APPDATA%\picgo\data.json
Linux: $XDG_CONFIG_HOME/picgo/data.json or ~/.config/picgo/data.json
macOS: ~/Library/Application\ Support/picgo/data.json

1.4.0-beta.2 在上传文件到 Backblaze B2 桶时不成功,日志是

------Error Stack Begin------
Error: Failed to upload to S3: Unsupported value for canned acl 'public-read'
    at Object.createUploadTask (/Users/fscarmen/Library/Application Support/picgo/node_modules/picgo-plugin-s3/dist/uploader.js:70:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)
    at async Object.upload [as handle] (/Users/fscarmen/Library/Application Support/picgo/node_modules/picgo-plugin-s3/dist/index.js:26:19)
    at async je.doUpload (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/picgo/dist/index.cjs.js:1:19834)
    at async je.start (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/picgo/dist/index.cjs.js:1:18605)
    at async $t.upload (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/picgo/dist/index.cjs.js:1:74899)
    at async Object.upload (/Applications/PicGo.app/Contents/Resources/app.asar/index.js:2:687302)
    at async mr (/Applications/PicGo.app/Contents/Resources/app.asar/index.js:2:690051)
-------Error Stack End------- 

之前使用1.3.9 上传这个B2 桶时,要把 ACL 那填留空。现在1.4.0-beta.2 我也是留空的,在配置信息里也是 "acl": "",,但看报错好像仍然是使用了acl: public-read ,请查查。

另外endpoint 一定要加上协议头https://,如果不加也能提交配置但上传会失败。而像b2桶这里没有提示https:// 。
大佬看如果简单容易处理的,希望可以加个提交限制,提示需要有协议。如果复杂的,在这里指示用户一下也好

image image

@wayjam
Copy link
Owner

wayjam commented Dec 11, 2024

@fscarmen R2的ACL设置成 private 试试

@fscarmen
Copy link

fscarmen commented Dec 11, 2024

@fscarmen R2的ACL设置成 private 试试

这个我之前试过了,忘记说而已。也是不行的。这个问题是在1.4.0才有的。已经试过3个方案,public-read, private 和留空

image
2024-12-11 19:51:10 [PicGo ERROR] 
------Error Stack Begin------
Error: Failed to upload to S3: UnknownError
    at Object.createUploadTask (/Users/fscarmen/Library/Application Support/picgo/node_modules/picgo-plugin-s3/dist/uploader.js:70:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)
    at async Object.upload [as handle] (/Users/fscarmen/Library/Application Support/picgo/node_modules/picgo-plugin-s3/dist/index.js:26:19)
    at async je.doUpload (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/picgo/dist/index.cjs.js:1:19834)
    at async je.start (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/picgo/dist/index.cjs.js:1:18605)
    at async $t.upload (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/picgo/dist/index.cjs.js:1:74899)
    at async Object.upload (/Applications/PicGo.app/Contents/Resources/app.asar/index.js:2:687302)
    at async mr (/Applications/PicGo.app/Contents/Resources/app.asar/index.js:2:690051)
-------Error Stack End------- 

@fscarmen
Copy link

fscarmen commented Dec 11, 2024

大佬,唔係 R2啊(这个没有问题),係 Backblaze B2 桶。一係你留email俾我,我直接俾个b2桶你试,咁样快D

@wayjam
Copy link
Owner

wayjam commented Dec 11, 2024

大佬,唔係 R2啊(这个没有问题),係 Backblaze B2 桶。一係你留email俾我,我直接俾个b2桶你试,咁样快D

奇怪 B2 我也是用了 private 上传成功了。我在 v1.4.0-beta.3 将 ACL 默认值恢复成空,你试下如果还不行,你可以在我 blog 的 about 页找到 email。

@fscarmen
Copy link

fscarmen commented Dec 11, 2024

可以了,大佬。我定点到问题了,我上传的测试图片文件名有空格,导致不成功,这个是上几天别人使用我项目同步时,说有空格的文件会出问题,我弄了一个测试的,忘记这点了。真是对唔住大佬。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants