Пример #1
0
 def testProvenanceFileWithoutItem(self):
     fileData = b'this is a test'
     file = Upload().uploadFromFile(
         obj=six.BytesIO(fileData), size=len(fileData), name='test',
         parentType=None, parent=None, user=self.admin)
     self.assertIsNone(file.get('itemId'))
     file['name'] = 'test2'
     file = File().save(file)
     File().remove(file)
Пример #2
0
 def testProvenanceFileWithoutItem(self):
     fileData = b'this is a test'
     file = Upload().uploadFromFile(obj=six.BytesIO(fileData),
                                    size=len(fileData),
                                    name='test',
                                    parentType=None,
                                    parent=None,
                                    user=self.admin)
     self.assertIsNone(file.get('itemId'))
     file['name'] = 'test2'
     file = File().save(file)
     File().remove(file)
Пример #3
0
    def finalizeUpload(self, upload):
        user = self.getCurrentUser()

        if upload['userId'] != user['_id']:
            raise AccessException('You did not initiate this upload.')

        # If we don't have as much data as we were told would be uploaded and
        # the upload hasn't specified it has an alternate behavior, refuse to
        # complete the upload.
        if upload['received'] != upload['size'] and 'behavior' not in upload:
            raise RestException(
                'Server has only received %s bytes, but the file should be %s bytes.' %
                (upload['received'], upload['size']))

        file = Upload().finalizeUpload(upload)
        extraKeys = file.get('additionalFinalizeKeys', ())
        return self._model.filter(file, user, additionalKeys=extraKeys)
Пример #4
0
    def finalizeUpload(self, upload):
        user = self.getCurrentUser()

        if upload['userId'] != user['_id']:
            raise AccessException('You did not initiate this upload.')

        # If we don't have as much data as we were told would be uploaded and
        # the upload hasn't specified it has an alternate behavior, refuse to
        # complete the upload.
        if upload['received'] != upload['size'] and 'behavior' not in upload:
            raise RestException(
                'Server has only received %s bytes, but the file should be %s bytes.' %
                (upload['received'], upload['size']))

        file = Upload().finalizeUpload(upload)
        extraKeys = file.get('additionalFinalizeKeys', ())
        return self._model.filter(file, user, additionalKeys=extraKeys)