Skip to content

Wiki:Confluence HTML 图片 #13

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

Closed
shaunthegeek opened this issue Jul 6, 2021 · 7 comments
Closed

Wiki:Confluence HTML 图片 #13

shaunthegeek opened this issue Jul 6, 2021 · 7 comments
Assignees

Comments

@shaunthegeek
Copy link
Member

HTML 中带了 图片,需要上传贴图

@shaunthegeek shaunthegeek self-assigned this Jul 6, 2021
@shaunthegeek
Copy link
Member Author

初步方案:前端上传图片到 CODING,替换 HTML 中图片链接。

调研发现:CODING 没有上传图片的接口,而提供了 上传 zip 的接口:

https://help.coding.net/openapi#9c802a105eb5c9b336871209f6feedf0

而 zip 是什么格式呢?文档没说明。

在网页后台找到了:

Zip 文件需包含 1 个 Markdown 文件及全部引用图片

image

看来这样更方便,文章里的多张图一次全部上传。

@shaunthegeek
Copy link
Member Author

实测,一次导入 2 篇也可以

image

shaunthegeek added a commit that referenced this issue Jul 6, 2021
@shaunthegeek
Copy link
Member Author

CODING 接口使用 文件名 作为文章标题,而 Confluence 文件名为英文或数字,没法用。参考 #11 (comment)

所以,需要先创建 wiki,后修改名字。

那么最好是:一次上传一篇,改名字。那需要解析 markdown,获取图片,把一个 md 和几张图片压成 zip,上传。这个解析是必须的,因为还有附件需要处理。

如果一次上传所有,再改名字,行不行?其实也行。

@shaunthegeek
Copy link
Member Author

shaunthegeek commented Jul 7, 2021

发现一个坑:overtrue/laravel-filesystem-cos 临时上传密钥 无法使用 laravel storage 上传。

image

经排查,overtrue 不是基于腾讯官方 SDK,而腾讯官方已支持 https://cloud.tencent.com/document/product/436/14048

tencentyun/cos-php-sdk-v5@8800630

image

@shaunthegeek
Copy link
Member Author

发现一个坑:腾讯官方 SDK 依赖的 guzzle 版本太低,安装不上……

image

@shaunthegeek
Copy link
Member Author

为了解决上面的问题,fork 了两个包,升级了依赖:
https://github.com/sinkcup/laravel-filesystem-cos
https://github.com/sinkcup/cos-php-sdk-v5

安装成功。运行报错:

The Access Key Id you provided does not exist in our records

搜索发现,可能是:缺少临时 token

https://cloud.tencent.com/developer/ask/203132

检查代码发现,cos 官方 sdk 没问题 https://github.com/sinkcup/cos-php-sdk-v5/blob/b8174cb10c535b596cf1c5b58301d2317b81132a/src/Qcloud/Cos/Client.php#L113

而 laravel-filesystem-cos 没有传递进去,修改配置增加 token,成功:

'cos' => [
            'driver' => 'cos',
            'region'          => env('COS_REGION', 'ap-guangzhou'),
            'credentials'     => [
                'appId'     => env('COS_APP_ID'),
                'secretId'  => env('COS_SECRET_ID'),
                'secretKey' => env('COS_SECRET_KEY'),
                'token'     => env('COS_TOKEN'),
            ],
            'timeout'         => env('COS_TIMEOUT', 60),
            'connect_timeout' => env('COS_CONNECT_TIMEOUT', 60),
            'bucket'          => env('COS_BUCKET'),
            'cdn'             => env('COS_CDN'),
            'scheme'          => env('COS_SCHEME', 'https'),
            'read_from_cdn'   => env('COS_READ_FROM_CDN', false),
        ],

shaunthegeek added a commit that referenced this issue Jul 8, 2021
shaunthegeek added a commit that referenced this issue Jul 8, 2021
shaunthegeek added a commit that referenced this issue Jul 8, 2021
shaunthegeek added a commit that referenced this issue Jul 8, 2021
shaunthegeek added a commit that referenced this issue Jul 8, 2021
shaunthegeek added a commit that referenced this issue Jul 8, 2021
shaunthegeek added a commit that referenced this issue Jul 8, 2021
shaunthegeek added a commit that referenced this issue Jul 8, 2021
shaunthegeek added a commit that referenced this issue Jul 8, 2021
shaunthegeek added a commit that referenced this issue Jul 8, 2021
shaunthegeek added a commit that referenced this issue Jul 8, 2021
@shaunthegeek
Copy link
Member Author

wiki 不支持 svg,暂不处理,或者和附件一起处理。

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

1 participant