bepasty / bepasty-server

universal pastebin server
https://bepasty-server.readthedocs.org/
BSD 2-Clause "Simplified" License
194 stars 47 forks source link

howto upload a file using curl? #125

Open mfa opened 9 years ago

mfa commented 9 years ago

no I don't want to use the cli-client.

I tried: curl -F 'file=@filename.ext;type=application/octet-stream' https://user:token@paste.example.org/apis/rest/items -X POST

And get:

<html>
<head><title>413 Request Entity Too Large</title></head>
<body bgcolor="white">
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>

The documentation is no help because a curl example is missing.

NotANormalNerd commented 9 years ago

http://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/ Classic not my problem....

NotANormalNerd commented 9 years ago

And since you want to upload the file in one chunk, you will have to have a look at this: http://bepasty-server.readthedocs.org/en/latest/quickstart.html#bepasty.config.Config.MAX_BODY_SIZE

mfa commented 9 years ago

ok. the easiest way is to change the nginx configuration: client_max_body_size 3G;

Now this works:

curl -F 'file=@filename.ext;type=application/octet-stream' https://user:token@paste.example.org/+upload -X POST

Answer:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="/Ywa79Uxx#filename.ext>/Ywa79Uxx#filename.ext</a>.  If not click the link.

everything fine now.

NotANormalNerd commented 9 years ago

You changed from rest-api to normal web? Didn't it work with the rest api?

mfa commented 9 years ago
curl -F 'file=@filename.ext;type=application/octet-stream' https://user:token@paste.example.org/apis/rest/items -X POST

curl: (18) transfer closed with 27 bytes remaining to read

and /+list returns now Errorcode 500, because .data and .meta are 0 byte. #yay

NotANormalNerd commented 9 years ago

I will rework the rest api to make is usable with curl and/or other similr tools

makefu commented 9 years ago

any updates on this one? The empty metadata issue seems to be a dupe of #126 . with pull request #128 retrieval of all files, even if metadata are corrupted or unreadable.

maybe the api could be used for the web interface to avoid server error?