7
7
8
8
> Élan is a vscode extension focus on uploading image to Alibaba Cloud (Aliyun) OSS.
9
9
10
+ [ English README] ( https://github.com/fangbinwei/aliyun-oss-uploader/blob/master/README_en_US.md )
11
+
10
12
## Support
11
13
If you find it useful, please [ star me on Github] ( https://github.com/fangbinwei/aliyun-oss-uploader ) .
12
14
13
15
## Usage
14
16
15
- 1 . You should create the [ OSS instance ] ( https://www.aliyun.com/product/oss/?lang=en ) and get the ` accessKeyId ` and ` accessKeySecret ` . Then you should create bucket instance and get the ` bucket ` name. [ see chapter 'Create bucket' ] ( #create-bucket )
17
+ 1 . 首先需要在阿里云上创建一个 [ OSS实例 ] ( https://www.aliyun.com/product/oss/?lang=en ) , 创建一个新的bucket, 获取 ` accessKeyId ` and ` accessKeySecret ` , 具体可以参考 [ 这里 ] ( #create-bucket )
16
18
17
- 2 . Setting the configuration of the extension
19
+ 2 . 设置插件的配置
18
20
19
- - Click button to set the configuration.
20
- - Open the command panel (` ctrl+shift+p ` /` command+shift+p ` /` F1 ` ) and type ` elan set configuration ` .
21
+ - 初次使用可以在侧边栏点击插件的图标, 里面有个按钮可以帮助设置配置.
22
+ - 在命令面板(` ctrl+shift+p ` /` command+shift+p ` /` F1 ` )输入` elan set configuration ` , 和上面点击按钮设置配置的效果一样.
23
+ - 当然也可以直接在vscode的配置页面找到本插件, 进行配置
21
24
22
25
![ set configuration] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/setConfiguration.png )
23
26
24
27
25
- ### Upload Image(s)
28
+ ### 上传图片
29
+
30
+ * bucket树上传指定图片/剪贴板中的图片
31
+ * 使用命令来上传指定图片/剪贴板中的图片
32
+ - 在命令版中输入'elan' 可以看到对应命令
33
+
34
+ * 在vscode的文件explorer中右键图片, 选择上传(` Elan: upload image ` )
26
35
27
- * Upload image through bucket treeView.
28
- * Open the command panel and type 'elan'.
29
- - upload image from clipboard
30
- - upload image from explorer
36
+ ### 删除已上传的图片
37
+ * bucket树中右键要删除的图片, 进行删除
31
38
32
- * Right click the image of file explorer, click the menu item ` Elan: upload image`
39
+ * 在markdown中, 鼠标hover到图片的语法上, 点击 ` Delete image`
33
40
34
- ### Delete Image
35
- * Delete the image by bucketView
41
+ > 暂时只支持markdown的图片语法
36
42
37
- * Hover the image syntax in markdown, click ` Delete image ` to delete the image in OSS.
43
+ ### 预览bucket中的图片
44
+ 图片上传到OSS的bucket中后, 可以在bucket树中, 点击要预览的图片进行预览.
38
45
39
- > only support image syntax now
46
+ ![ image preview ] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/image-preview.png )
40
47
41
48
### Usage Demo (Bucket TreeView)
42
49
43
- #### Upload Image from File Explorer/ Clipboard
44
- Right click the folder, and upload image
50
+ #### 上传系统中的图片/剪贴板中的图片
51
+ 在bucket树中, 右键‘文件夹’或者bucket, 然后填写上传路径, 选择上传的图片, 进行上传. 上传完后, 你的剪贴板中会有markdown图片语法的输出, 你可以直接粘贴进行使用. 如果你已经打开了一个markdown文件, 会自动粘贴到你的文件中.
45
52
46
53
![ bucketTreeView_upload] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/bucketTreeView_upload_9d027122.png )
47
54
48
- #### Copy/Move/Rename/Delete Image in Bucket TreeView
49
- Right click the image, and copy/move/delete the image .
55
+ #### 复制/移动/重命名/删除 bucket中的图片
56
+ 在bucket树中, 右键要操作的图片, 选择复制, 然后填写目标路径, 进行复制. 选择移动/重命名, 则要求填写的目标名称(包括路径和文件名) .
50
57
51
58
![ bucketTreeView_delete_copy_move] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/bucketTreeView_delete_copy_move_240549f5.png )
52
59
53
- ### Copy Link
60
+ ### 复制bucket中对象的链接
61
+ 点击文件右侧的链接🔗图标, 即可复制
54
62
55
63
![ bucketTreeView_copy_link] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/bucketTreeView_copy_link_6e710ef5.png )
56
64
57
65
### Usage Demo (Other)
58
66
59
- #### Upload from Clipboard
60
- Open the command panel and type ` elan upload from clipboard `
67
+ #### 使用命令上传剪贴板中的图片
68
+ 打开命令面板, 输入 ` elan upload from clipboard `
61
69
62
70
![ updateFromClipboard] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/updateFromClipboard_bf2399e2.gif )
63
71
64
- #### Upload by Explorer Dialog
65
-
66
- Open the command panel and type ` elan upload from explorer `
72
+ #### 通过vscode的dialog选择图片上传
73
+ 打开命令面板, 输入` elan upload from explorer `
67
74
68
75
![ updateFromExplorer] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/updateFromExplorer_9f6ee648.gif )
69
76
70
77
71
- #### Upload by Explorer Context
72
- Right click the image in vscode file explorer, choose ` elan: upload image `
78
+ #### 在vscode的文件explorer选择文件上传
79
+ 在文件explorer中, 右键要上传的图片, 选择 ` elan: upload image `
73
80
74
81
![ updateFromExplorerContext] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/updateFromExplorerContext_37c3aac0.gif )
75
82
76
- #### Delete Image (Hover)
83
+ #### 通过hover删除图片
77
84
78
85
![ hoverDeleteCut] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/hoverDeleteCut_f9af47b7.png )
79
86
80
87
![ hoverDelete] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/hoverDelete_03dc5db7.gif )
81
88
82
- > demo gif upload by this vscode extension.
89
+ > 本README中所用的图片都是用本插件上传的
83
90
84
- ## Configuration
91
+ ## 配置信息
85
92
### ` elan.aliyun.accessKeyId `
86
93
### ` elan.aliyun.accessKeySecret `
87
94
### ` elan.aliyun.bucket `
88
95
### ` elan.aliyun.region `
89
- e.g. ` oss-cn-shanghai ` , [ check details ] ( https://github.com/ali-sdk/ali-oss#data-regions ) .
96
+ 例如 ` oss-cn-shanghai ` , [ 具体可以查看这里 ] ( https://github.com/ali-sdk/ali-oss#data-regions ) .
90
97
91
98
### ` elan.uploadName `
92
- Object name store on OSS
99
+ 所上传的OSS对象, 在OSS中的命名
100
+
101
+ 默认格式: ` ${fileName}_${contentHash:8}${ext} `
93
102
94
- Default: ` ${fileName}_${contentHash:8}${ext} `
103
+ - ` ${fileName} ` : 所上传的文件名
104
+ - ` ${ext} ` : 所上传文件的扩展后缀, 例如` .png ` .
105
+ - ` ${contentHash} ` : 文件内容的hash值. 和webpack的` contentHash ` 类似, 也可以指定选择使用的位数.
106
+ - ` ${activeMdFilename} ` : 如果当前打开了markdown文件, 这个就指所打开md文件的文件名.
95
107
96
- - ` ${fileName} ` : Filename of uploaded file.
97
- - ` ${ext} ` : Filename extension of uploaded file.
98
- - ` ${contentHash} ` : The hash of image. By default, it's the hex digest of md5 hash. You can specify the length of the hash, e.g. ` ${contentHash:8} ` .
99
- - ` ${activeMdFilename} ` : Filename of active markdown in text editor.
108
+ ` contentHash ` 的计算方式, ` ${<hashType>:hash:<digestType>:<length>} ` , 默认` hashType ` 是` md5 ` , ` digestType ` 为` hex `
100
109
101
- Support ` ${<hashType>:hash:<digestType>:<length>} ` , default:
102
110
``` js
103
111
crypto .createHash (' md5' )
104
112
.update (imageBuffer)
@@ -108,22 +116,28 @@ crypto.createHash('md5')
108
116
```
109
117
110
118
### ` elan.outputFormat `
111
- After uploading image, this output will be pasted to your clipboard. If you have opened a * .md, this will be pasted to your markdown automatically .
119
+ 成功上传后, 剪贴板中会有一段输出的字符串, 这个配置决定了输出字符串的格式. 如果你当前打开了一个markdown文件, 这段字符串会自动插入到你的markdown文件中 .
112
120
113
- - ` ${fileName} ` : Filename of uploaded file.
114
- - ` ${uploadName} ` : see ` elan.uploadName ` .
115
- - ` ${url} ` : After a file is uploaded successfully, the OSS sends a callback request to this URL .
116
- - ` ${activeMdFilename} ` : Filename of active markdown in text editor .
121
+ - ` ${fileName} ` : 文件名
122
+ - ` ${uploadName} ` : 在oss中所保存的文件名, 是在 ` elan.uploadName ` 中配置的 .
123
+ - ` ${url} ` : 文件的url .
124
+ - ` ${activeMdFilename} ` : 如果上传的时候, 打开了md文件, 这个就是md文件名 .
117
125
118
126
### ` elan.bucketFolder `
119
- By default, you can find your image object by ` elan.uploadName ` , e.g. ` example.png ` . If we set ` elan.bucketFold ` to ` github/aliyun-oss-uploader ` , our images will be upload to "folder" ([ not a real folder] ( https://help.aliyun.com/document_detail/31827.html ) ). You can find uploaded image in "folder" ` github/aliyun-oss-uploader/ ` .
127
+ > 如果你觉得这个配置有点复杂, 又想将文件上传到指定的文件夹, 建议在bucket树中上传
128
+
129
+ 默认情况, 你的文件上传到bucket后, 它都是在bucket的‘根目录’, 文件命名是由` elan.uploadName ` 决定的. 但是有时候希望能用‘文件夹’来组织所上传的文件, 这个配置就有用了.
130
+
131
+ > 如果在bucket树中上传, 则不需要这个配置, 因为bucket树中上传的时候可以直接指定文件路径
132
+
133
+ 举个例子, 上传` example.png ` . 如果设置` elan.bucketFold ` 为 ` github/aliyun-oss-uploader ` , 那我们的图片就会被上传到"文件夹" ` github/aliyun-oss-uploader/ ` 中. 我们这里提到的文件夹和传统的文件夹不一样, [ OSS只是模拟了文件夹] ( https://help.aliyun.com/document_detail/31827.html ) , 其实我们上传的` example.png ` 在OSS中保存的是` github/aliyun-oss-uploader/example.png ` , OSS只是用` / ` 分割符来模拟文件夹.
120
134
121
135
![ oss browser] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/2020-05-31-19-02-13_55660788.png )
122
136
123
- - ` ${relativeToVsRootPath} ` : The path of the directory where the currently active file is located relative to the workspace root directory
124
- - ` ${activeMdFilename} ` : Filename of active markdown in text editor .
137
+ - ` ${relativeToVsRootPath} ` : 这个配置比较抽象, 假如我们上传的时候, vscode编辑器有打开一个文件, 那这个配置就指代所打开文件所在的路径
138
+ - ` ${activeMdFilename} ` : 如果打开了一个markdown文件, 这个配置就指md文件的文件名 .
125
139
126
- For example, you set ` elan.bucketFold ` to ` blog/${relativeToVsRootPath}/ ` , and workspace is like below
140
+ 举个例子, 设置 ` elan.bucketFolder ` 为 ` blog/${relativeToVsRootPath}/ ` , vscode的explorer如下
127
141
128
142
``` bash
129
143
.
@@ -134,11 +148,11 @@ For example, you set `elan.bucketFold` to `blog/${relativeToVsRootPath}/`, and w
134
148
│ └── example.md
135
149
```
136
150
137
- If you open the ` example.md ` by text editor, the "folder" will be ` blog/FrontEnd/Engineering/webpack/ ` .
151
+ 如果你打开了 ` example.md ` , 那 ` elan.bucketFolder ` 结果为 ` blog/FrontEnd/Engineering/webpack/ ` .
138
152
139
- Or you set ` elan.bucketFold ` to ` blog/${relativeToVsRootPath}/${activeMdFilename}/ ` , the "folder" will be ` blog/FrontEnd/Engineering/webpack/example/ ` .
153
+ 如果设置 ` elan.bucketFold ` 为 ` blog/${relativeToVsRootPath}/${activeMdFilename}/ ` ,` elan.bucketFolder ` 结果为 ` blog/FrontEnd/Engineering/webpack/example/ ` .
140
154
141
- If no file is opened , ` ${relativeToVsRootPath} ` will be parsed to ` '' ` , . If no active markdown, ` ${activeMdFilename} ` will be parsed to ` '' ` .
155
+ 如果没有打开文件 , ` ${relativeToVsRootPath} ` 会被解析成空字符 ` '' ` , ` ${activeMdFilename} ` 同理 .
142
156
143
157
| opened file | ` blog/${relativeToVsRootPath}/ ` | ` blog/${relativeToVsRootPath}/${activeMdFilename}/ ` |
144
158
| ---------- | --- | --- |
@@ -151,17 +165,11 @@ If no file is opened, `${relativeToVsRootPath}` will be parsed to `''`, . If no
151
165
152
166
![ create-bucket] ( https://fangbinwei-blog-image.oss-cn-shanghai.aliyuncs.com/github/aliyun-oss-uploader/create-bucket_5f7df897.png )
153
167
154
- ## Debugger Project
155
-
156
- If you want to debugger the project, just press ` F5 ` to Run Extension. Then we can debugger the output of webpack dist.
157
-
158
- > since ` @types/ali-oss ` is outdated you may see some ts error in your local
159
-
160
- <!-- ## WIP
168
+ ## 调试项目
161
169
162
- working in bucket explorer
170
+ 如果你想调试这个项目, 可以按 ` F5 ` , 然后就可以调试webpack输出的dist目录
163
171
164
-  -->
172
+ > 因为 ` @types/ali- oss` 有点过时, 你会看到一些ts的报错
165
173
166
174
## TODO
167
175
@@ -176,9 +184,9 @@ working in bucket explorer
176
184
* [x] enhance 'bucketFolder'
177
185
* [x] delete image when hover GFM(github flavored markdown)
178
186
* [x] sidebar extension (e.g. show recent uploaded image)/ (should consider icon theme)
187
+ * [x] preview image of bucket by webview (WIP)
179
188
* [ ] recently uploaded show in bucket treeView
180
189
* [ ] bucket treeView pagination/ batch operation (WIP)
181
- * [ ] preview image of bucket by webview (WIP)
182
190
* [ ] confirmation before deleting image
183
191
* [ ] inquire before upload to check folder
184
192
* [ ] decoupling logic by tapable
0 commit comments