Пример #1
0
def upload_asset_file(asset, orig_file_name):
    """ Upload an asset file
    """
    keys = asset.owner.encryption_keys.all()
    if len(keys) == 0:
        file_name = orig_file_name
        logging.warn("%s is not secure" % asset.owner)
    else:
        file_name = '%s.enc' % orig_file_name
        secure_file(keys[0].value, ENCRYPT, orig_file_name, file_name)

    s3.upload_from_file(asset.s3_key, file_name, asset.mime_type.name)

    if file_name != orig_file_name:
        os.remove(file_name)
Пример #2
0
    def test_upload_from_file(self):

        s3.initialize()

        s3_path = 'test-directory/test_002_upload_from_file.txt'

        file_descriptor, local_path = tempfile.mkstemp(suffix='.txt')
        try:
            try:
                os.write(file_descriptor, self.content)
            finally:
                os.close(file_descriptor)

            s3.upload_from_file(s3_path, local_path, self.content_type)
        finally:
            os.remove(local_path)

        self._validate_and_remove_upload(s3_path)
Пример #3
0
    def test_upload_from_file(self):

        s3.initialize()

        s3_path = 'test-directory/test_002_upload_from_file.txt'

        file_descriptor, local_path = tempfile.mkstemp(suffix='.txt')
        try:
            try:
                os.write(file_descriptor, self.content)
            finally:
                os.close(file_descriptor)

            s3.upload_from_file(
                s3_path,
                local_path,
                self.content_type)
        finally:
            os.remove(local_path)

        self._validate_and_remove_upload( s3_path )
Пример #4
0
def upload_asset_file( asset, orig_file_name ):
    """ Upload an asset file
    """
    keys = asset.owner.encryption_keys.all()
    if len(keys) == 0:
        file_name = orig_file_name
        logging.warn("%s is not secure" % asset.owner)
    else:
        file_name = '%s.enc' % orig_file_name
        secure_file(
            keys[0].value,
            ENCRYPT,
            orig_file_name,
            file_name )

    s3.upload_from_file(
        asset.s3_key,
        file_name,
        asset.mime_type.name )

    if file_name != orig_file_name:
        os.remove(file_name)