A picgo plugin to format filename by your setting.
npm install picgo-plugin-filename-formatA picgo plugin to format filename by your setting.
``sh`Mac
cd ~/.picgo && npm i --save picgo-plugin-filename-formatWindows
cd C:\\Users\\
After install this plugin, you should edit .picgo/config.json like this
`json`
{
"picBed": {
"uploader": "aliyun",
"aliyun": {
// ...
},
"current": "aliyun"
},
"picgoPlugins": {
// use this plugin
"picgo-plugin-filename-format": true
},
// config how to format your file name
"picgo-plugin-filename-format": {
// format type (e.g. origin/hash/uuid/timestamp/time)
"format": "hash",
// format options
"options": {
"type": "sha256",
"length": 16
}
}
}
Now you can run picgo u or upload file by Typora, and the file name will be formatted according to your setting before upload.
If you upload an image call demo.png
`txt
// format: origin
https://cloud.com/images/demo.png
// format: hash
https://cloud.com/images/F797b746fa17615e.png
// format: uuid
https://cloud.com/images/b117132a-1df4-47dd-b861-a4a2eb687703.png
// format: timestamp
https://cloud.com/images/1705770275093.png
// format: time
https://cloud.com/images/2024-01-01/demo.png // nameFormat: origin
https://cloud.com/images/2024-01-01/F797b746fa17615e.png // nameFormat: hash
https://cloud.com/images/2024-01-01/1705770275093.png // nameFormat: timestamp
`
| Field Name | Field Type | Description |
| -- | -- | -- |
| format | string | Format type (default origin) origin
e.g. , uuid, hash, time, timestamp |
| options | object | Format options, every format type has different options |
Format type origin need't to set options.
Format type uuid need't to set options.
| Field Name | Field Type | Description |
| -- | -- | -- |
| type | string | Hash algorithm that supported by OpenSSL (default sha256) sha256
e.g. , sha512, etc |32
| length | number | The hash output length (default ) 8
e.g. , 16, 32, etc |
Example
`json`
{
"format": "hash",
"options": {
"type": "sha256",
"length": 16
}
}
| Field Name | Field Type | Description |
| -- | -- | -- |
| length | number | The timestamp output length (default 13) 10
e.g. , 13 |
Example
`json`
{
"format": "timestamp",
"options": {
"length": 13
}
}
| Field Name | Field Type | Description |
| -- | -- | -- |
| timeFormat | string | Time prefix format template that supported by dayjs (default YYYY-MM-DD) |origin
| nameFormat | string | File name format type, supporting above types (default ) origin
e.g. , uuid, hash, timestamp |
| nameOptions | object | File name format options |
Example
`json``
{
"format": "time",
"options": {
"timeFormat": "YYYYMMDDHHmmss",
"nameFormat": "hash",
"nameOptions": {
"length": 16
}
}
}