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

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.