def expires_at(self):
return self.data.expires_at
+ async def has_payload(self):
+ """
+ Returns True if this upload has received its payload
+ """
+ # We must have a path
+ if not self.path:
+ return False
+
+ # The data must exist on disk
+ return await self.backend.exists(self.path)
+
async def copyfrom(self, src):
"""
Copies the content of this upload from the source file descriptor
"""
+ # Cannot do this if we already have a payload
+ if await self.has_payload():
+ raise FileExistsError("We already have the payload")
+
# Reset the source file handle
src.seek(0)
allow_users = True
@base.negotiate
- def get(self):
+ async def get(self):
uploads = []
for upload in self.current_user.uploads:
"created_at" : upload.created_at.isoformat(),
"expires_at" : upload.expires_at.isoformat(),
+
+ # Show whether we have received the payload
+ "has-payload": await upload.has_payload(),
})
self.finish({