uploade
This commit is contained in:
pare
d2a5336972
commit
e3fa9829d3
S'han modificat 2 arxius amb 49 adicions i 0 eliminacions
2
test.csv
Normal file
2
test.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
upload|test
|
||||
testing|1
|
|
47
test.py
Normal file
47
test.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
import os
|
||||
from datetime import datetime
|
||||
import base64
|
||||
import requests
|
||||
from requests.models import urlencode
|
||||
import pdb
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
filename = 'test.csv'
|
||||
|
||||
with open(filename, 'rb') as input_file:
|
||||
data = input_file.read()
|
||||
file = base64.b64encode(data)
|
||||
|
||||
owner = "spla"
|
||||
repo = "upload"
|
||||
author_email = "spla@mastodont.cat"
|
||||
author_name = "spla"
|
||||
branch = "main"
|
||||
content = file
|
||||
message = f'file {filename} uploaded'
|
||||
|
||||
api_base_url = "https://git.mastodont.cat"
|
||||
|
||||
data = {"author":[{"email":author_email},{"name":author_name}],
|
||||
"branch":branch,
|
||||
"content":content,
|
||||
"message":message
|
||||
}
|
||||
|
||||
params = dict()
|
||||
params['token'] = 'token_here'
|
||||
formatted_params = urlencode(params)
|
||||
|
||||
endpoint = api_base_url + '/api/v1/repos/{0}/{1}/contents/{2}?{3}'.format(owner, repo, filename, formatted_params)
|
||||
|
||||
try:
|
||||
|
||||
response = requests.post(endpoint, data)
|
||||
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
Loading…
Referencia en una nova incidència