Created
March 27, 2020 04:15
-
-
Save LeoQuote/61d6c6d81745a4a75834054d7ce778ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import ssl | |
import json | |
import base64 | |
github_base_url = 'https://api.github.com' | |
username = 'LeoQuote' | |
password = 'token' | |
org = 'LeoQuote' | |
repo = 'test-repo' | |
path = 'test-bin' | |
s = requests.session() | |
s.auth = (username, password) | |
bin_file = ssl.RAND_bytes(48) | |
print(len(bin_file)) | |
s.put(f"{github_base_url}/repos/{org}/{repo}/contents/{path}", | |
data=json.dumps({ | |
'message': 'add bin', | |
'content': base64.b64encode(bin_file).decode() | |
})) | |
r = s.get(f"{github_base_url}/repos/{org}/{repo}/contents/{path}") | |
content_github = base64.b64decode(r.json()['content'].encode()) | |
print(len(content_github)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment