docs(readme): add Python API upload example with code snippets and limits
This commit is contained in:
57
README.md
57
README.md
@@ -69,6 +69,63 @@ Next steps (optional)
|
|||||||
License
|
License
|
||||||
- MIT or your preferred license (update as needed)
|
- MIT or your preferred license (update as needed)
|
||||||
|
|
||||||
|
API Usage (Python)
|
||||||
|
|
||||||
|
Upload a file via the API endpoint:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import requests
|
||||||
|
|
||||||
|
BASE_URL = "http://23.226.133.121:5000"
|
||||||
|
|
||||||
|
expiry = "24h" # 1h, 24h, 7d
|
||||||
|
|
||||||
|
with open("/path/to/your/file.zip", "rb") as f:
|
||||||
|
resp = requests.post(
|
||||||
|
f"{BASE_URL}/api/upload",
|
||||||
|
files={"file": ("file.zip", f)},
|
||||||
|
data={"expiry": expiry},
|
||||||
|
)
|
||||||
|
|
||||||
|
if resp.status_code == 200:
|
||||||
|
data = resp.json()
|
||||||
|
print(f"Share URL: {data['share_url']}")
|
||||||
|
print(f"File ID: {data['id']}")
|
||||||
|
print(f"Size: {data['filesize']} bytes")
|
||||||
|
else:
|
||||||
|
print(f"Upload failed: {resp.json()['error']}")
|
||||||
|
```
|
||||||
|
|
||||||
|
Response format:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "550e8400-e29b-41d4-a716-446655440000",
|
||||||
|
"filename": "file.zip",
|
||||||
|
"filesize": 1048576,
|
||||||
|
"expiry_hours": 24,
|
||||||
|
"share_url": "http://23.226.133.121:5000/file/550e8400..."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Get file info via API:
|
||||||
|
```python
|
||||||
|
resp = requests.get(f"{BASE_URL}/api/file/{file_id}")
|
||||||
|
if resp.status_code == 200:
|
||||||
|
info = resp.json()
|
||||||
|
print(f"Daily upload: {info['daily_upload']} bytes")
|
||||||
|
print(f"Daily download: {info['daily_download']} bytes")
|
||||||
|
print(f"Traffic limit: {info['traffic_limit']} bytes (20GB)")
|
||||||
|
```
|
||||||
|
|
||||||
|
Or use the bundled client script:
|
||||||
|
```bash
|
||||||
|
python upload_client.py /path/to/file.zip 24h
|
||||||
|
```
|
||||||
|
|
||||||
|
Limits
|
||||||
|
- Maximum file size: 500 MB
|
||||||
|
- Per-IP daily traffic limit: 20 GB (upload + download combined)
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
- Pull requests are welcome. Please follow the project style and ensure tests pass.
|
- Pull requests are welcome. Please follow the project style and ensure tests pass.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user