Skip to content

Commit

Permalink
Merge pull request #25 from MrZilinXiao/master
Browse files Browse the repository at this point in the history
base64 to_file support
  • Loading branch information
wj-Mcat committed Aug 4, 2020
2 parents 6ca8152 + 45cce07 commit b50110f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.0.15
0.0.16
7 changes: 6 additions & 1 deletion src/wechaty_puppet/file_box/file_box.py
Expand Up @@ -4,7 +4,7 @@
from __future__ import annotations

import json

import base64
import requests
import os
from collections import defaultdict
Expand Down Expand Up @@ -177,6 +177,11 @@ async def to_file(self, file_path: Optional[str] = None,
img = qrcode.make(self.qrCode)
img.get_image().save(f)

elif file_box_type == FileBoxType.Base64:
data = base64.b64decode(self.base64)
with open(file_path, 'wb') as f:
f.write(data)

def to_base64(self) -> str:
"""
transfer file-box to base64 string
Expand Down

0 comments on commit b50110f

Please sign in to comment.