1

Im trying To Make post requests (multipart/form-data) in this website https://gofile.io/?t=api

every time time i got an error when i try to upload file

my code

import requests
req = requests.session()
files= {'file': open("test.txt", 'rb')}
response = req.post('https://srv-file7.gofile.io/upload', files=files)
print(response.text)

I got error every time ,are smething missing in the code

asked Apr 30, 2020 at 0:48
1

1 Answer 1

1
from requests_toolbelt.multipart.encoder import MultipartEncoder
import requests
import json
mp_encoder = MultipartEncoder(
 fields={
 'filesUploaded': ('file_name.txt', open('file_name.txt', 'rb'))
 }
)
r = requests.post(
 'https://srv-file9.gofile.io/upload',
 data=mp_encoder,
 headers={'Content-Type': mp_encoder.content_type}
)
scrap = r.json()
# send "Token file" 123Abc
Token = scrap['data']['code']

Check this. It will work.

ouflak
2,56310 gold badges46 silver badges53 bronze badges
answered Mar 1, 2022 at 6:52
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.