def gofile_upload(files): """ Uploads to gofile.io """ try: global progress_state session = Session() with open(files, 'rb') as f: form = encoder.MultipartEncoder({ "file": (files, f, "application/octet-stream"), }) headers = { "Prefer": "respond-async", "Content-Type": form.content_type } r = session.post("https://srv-store1.gofile.io/uploadfile", headers=headers, data=form) session.close() resp = json.loads(r.content) if r.status_code == 200: gofile_url = f'https://gofile.io/d/{resp["data"]["code"]}' print(f'GoFile Uploaded: {gofile_url}') progress_state.append(1) if gui_state: gui.update_links(f'GoFile: {gofile_url}') else: print('Something else happened') except Exception as e: print('GoFile did not upload')
def anonfiles_upload(files): """ Uploads to anonfiles.io """ try: global progress_state session = Session() with open(files, 'rb') as f: form = encoder.MultipartEncoder({ "file": (files, f, "application/octet-stream"), }) headers = { "Prefer": "respond-async", "Content-Type": form.content_type } r = session.post("https://api.anonfiles.com/upload", headers=headers, data=form) session.close() resp = json.loads(r.content) if r.status_code == 200: print('AnonFiles Uploaded: ' + resp['data']['file']['url']['short']) progress_state.append(1) if gui_state: gui.update_links('AnonFiles: ' + resp['data']['file']['url']['short']) else: print('Something else happened') except Exception as e: print('AnonFiles did not upload')
def gofile_upload(files): try: session = requests.Session() with open(files, 'rb') as f: form = encoder.MultipartEncoder({ "file": (files, f, "application/octet-stream"), }) headers = {"Prefer": "respond-async", "Content-Type": form.content_type} r = session.post("https://srv-store1.gofile.io/uploadfile", headers=headers, data=form) session.close() resp = json.loads(r.content) if r.status_code == 200: print('GoFile Uploaded: ' + 'https://gofile.io/d/' + resp['data']['code']) if gui_state: gui.update_links('GoFile: ' + 'https://gofile.io/d/' + resp['data']['code']) else: print('Something else happened') except Exception as e: print('GoFile did not upload')