1

For anonfiles, they only give the curl function to upload a file,

curl -F "[email protected]" https://api.anonfiles.com/upload

and I want to use python requests for this.

I tried

import requests
data = requests.put(url = "https://api.anonfiles.com/upload",data=open('file.txt','r').read() )
print(data.text)

1 Answer 1

1

Try:

import requests

with open('test.txt', 'rb') as fp:
    r = requests.post('https://api.anonfiles.com/upload', files={'file': fp})
print(r.json())

Output:

{
    "status": true,
    "data": {
        "file": {
            "url": {
                "full": "https://anonfiles.com/oa28JcS2ya/test_txt",
                "short": "https://anonfiles.com/oa28JcS2ya"
            },
            "metadata": {
                "id": "oa28JcS2ya",
                "name": "test.txt",
                "size": {
                    "bytes": 580,
                    "readable": "580 B"
                }
            }
        }
    }
}

More information here: POST a Multipart-Encoded File

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.