820 日 , 2024 21:02:07
学而思图床

原作者开源了,我就把我这里的也发出来了。
侵删


import requests,json,os,hashlib,sys,pyperclip
from tkinter import *
from tkinter import messagebox as m


class XesUploader:

    # 文件相对路径
    def upload(self, relativeFilePath):
        absolutePath = relativeFilePath
        return self.uploadAbsolutePath(absolutePath)

    # 文件绝对路径
    def uploadAbsolutePath(self, filepath):
        md5 = None
        contents = None
        if os.path.isfile(filepath):
            fp = open(filepath, 'rb')
            contents = fp.read()
            fp.close()
            md5 = hashlib.md5(contents).hexdigest()

        if md5 is None or contents is None:
            raise Exception(f"文件 |{filepath}|不存在")

        uploadParams = self._getUploadParams(filepath, md5)
        requests.request(method="PUT", url=uploadParams['host'], data=contents, headers=uploadParams['headers'], proxies={"http": None, "https": None})
        return uploadParams['url']

    # 获取上传签名
    def _getUploadParams(self, filename, md5):
        url = 'https://code.xueersi.com/api/assets/get_oss_upload_params'
        params = {"scene": "offline_python_assets", "md5": md5, "filename": filename}
        response = requests.get(url=url, params=params, proxies={"http": None, "https": None})
        data = json.loads(response.text)['data']

        return data

uploader = XesUploader()
url = uploader.upload(sys.argv[1])
pyperclip.copy(url)
tk = Tk()
tk.withdraw()
m.showinfo("成功","已复制"+url)


暂无评论

发送评论 编辑评论

评论在正式发布之前会经过审核,请勿发表违反您所在地及中华人民共和国法律的言论。


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!