forked from MirrorHub/synapse
Small amounts of cleanup and bonus round comments.
This commit is contained in:
parent
58548ab557
commit
e37b040bc3
1 changed files with 8 additions and 4 deletions
|
@ -188,11 +188,13 @@ class ContentRepoResource(resource.Resource):
|
||||||
|
|
||||||
Uploads are POSTed to wherever this Resource is linked to. This resource
|
Uploads are POSTed to wherever this Resource is linked to. This resource
|
||||||
returns a "content token" which can be used to GET this content again. The
|
returns a "content token" which can be used to GET this content again. The
|
||||||
token is typically a path, but it may not be.
|
token is typically a path, but it may not be. Tokens can expire, be one-time
|
||||||
|
uses, etc.
|
||||||
|
|
||||||
In this case, the token contains 3 sections:
|
In this case, the token is a path to the file and contains 3 interesting
|
||||||
|
sections:
|
||||||
- User ID base64d (for namespacing content to each user)
|
- User ID base64d (for namespacing content to each user)
|
||||||
- random string
|
- random 24 char string
|
||||||
- Content type base64d (so we can return it when clients GET it)
|
- Content type base64d (so we can return it when clients GET it)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -205,7 +207,7 @@ class ContentRepoResource(resource.Resource):
|
||||||
|
|
||||||
if not os.path.isdir(self.directory):
|
if not os.path.isdir(self.directory):
|
||||||
os.mkdir(self.directory)
|
os.mkdir(self.directory)
|
||||||
logger.info("FileUploadResource : Created %s directory.",
|
logger.info("ContentRepoResource : Created %s directory.",
|
||||||
self.directory)
|
self.directory)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -271,6 +273,8 @@ class ContentRepoResource(resource.Resource):
|
||||||
f = open(file_path, 'rb')
|
f = open(file_path, 'rb')
|
||||||
request.setHeader('Content-Type', content_type)
|
request.setHeader('Content-Type', content_type)
|
||||||
d = FileSender().beginFileTransfer(f, request)
|
d = FileSender().beginFileTransfer(f, request)
|
||||||
|
|
||||||
|
# after the file has been sent, clean up and finish the request
|
||||||
def cbFinished(ignored):
|
def cbFinished(ignored):
|
||||||
f.close()
|
f.close()
|
||||||
request.finish()
|
request.finish()
|
||||||
|
|
Loading…
Reference in a new issue