I build a folder in gitee library.
I use picgo
to help me upload the pics. At the same time, I want to make a copy for the blog files.
I used git pull
command to help update the local file.
Meanwhile,I can directly add file into the local folder. And the below git command to upload it.
git add -A
git commit -m "add new pics"
git push
If we want to directly access the file, we can use the https://gitee.com/zhulinmails/git-images/raw/master/2021/
to concatenate with the local file name. The result is shown below.
https://gitee.com/zhulinmails/git-images/raw/master/2021/2021-08-02_165202.png
The exploration give us a new way to do the picture library in Gitee.
python script to generate the markdown link
If we concatenate the path by ourselves, it is very troublesome. Therefore I write a small python script to help to handle it. The performance is pretty good.
import os
import sys
import time
current_file_dir=os.path.dirname(os.path.abspath(__file__))
os.chdir(current_file_dir)
strBase="![{0}](https://gitee.com/zhulinmails/git-images/raw/master/2021/{1})"
exts=['.jpg','.png','.gif']
for root,dirs,files in os.walk("."):
for filename in files:
for ext in exts:
if filename.endswith(ext):
full_path=os.path.join(current_file_dir,filename)
file_modify_time=os.stat(full_path).st_mtime
if time.time()-file_modify_time<60*60*24:
print(strBase.format(filename,filename))
waitInput=input("请等待")