[Twisted-web] file upload with twisted
Аркадий Левин
poisonoff at gmail.com
Sat Jan 5 04:25:21 EST 2013
I resolve same problem in self project, reimplement method
handleContentChunk in server.Request
My code:
<code># For maximum
handleContentChunkLength = 0
def handleContentChunk(self, data):
"""
Write a chunk of data.
"""
self.handleContentChunkLength += len(data)
if self.handleContentChunkLength >= WEB_LIMIT_REQUEST_SIZE:
self.transport.write(b"HTTP/1.1 413 Request Entity Too Large\r\n\r\n")
self.transport.loseConnection()
# Raise to log error
raise ValueError('Maximum length equal')
self.content.write(data)</code>
On Sat, Jan 5, 2013 at 10:14 AM, Glyph <glyph at twistedmatrix.com> wrote:
>
> On Jan 4, 2013, at 5:50 PM, Levi Nie <levinie001 at gmail.com> wrote:
>
>> When i send a http request with a big file, can i check the content-length then enable or disable the
>> file upload?
>>
>> I use the s3cmd client sent the request. And i need disable the file upload if the file size is over the quota.
>>
>> how can i do this?
>
> This s3cmd? https://github.com/s3tools/s3cmd/blob/master/s3cmd
>
> It doesn't look like it uses Twisted, so I don't think this is a question for this list.
>
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
More information about the Twisted-web
mailing list