(self)
return self._upload_events(
            events=events, form=form, sketch=sketch, index_name=index_name)
Handles POST request to the resource.

        Returns:
            A view in JSON (instance of flask.wrappers.Response)
Handles POST request to the resource.
Handles POST request to the resource .
def post(self):
        """Handles POST request to the resource.

        Returns:
            A view in JSON (instance of flask.wrappers.Response)
        """
        upload_enabled = current_app.config['UPLOAD_ENABLED']
        if not upload_enabled:
            abort(HTTP_STATUS_CODE_BAD_REQUEST, 'Upload not enabled')

        form = request.get_data(parse_form_data=True)
        if not form:
            form = request.form

        sketch_id = form.get('sketch_id', None)
        if not sketch_id:
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Unable to upload data without supplying a '
                'sketch to associated it with.')

        if not isinstance(sketch_id, int):
            sketch_id = int(sketch_id)

        sketch = Sketch.query.get_with_acl(sketch_id)
        if not sketch:
            abort(
                HTTP_STATUS_CODE_NOT_FOUND,
                'No sketch found with this ID.')

        if sketch.get_status.status == 'archived':
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Unable to upload a file to an archived sketch.')

        if not sketch.has_permission(current_user, 'write'):
            abort(
                HTTP_STATUS_CODE_FORBIDDEN,
                'Unable to upload data to a sketch, user does not have '
                'write access.')

        utils.update_sketch_last_activity(sketch)

        index_name = form.get('index_name', '')
        file_storage = request.files.get('file')
        if file_storage:
            chunk_index_name = form.get('chunk_index_name', uuid.uuid4().hex)
            return self._upload_file(
                file_storage=file_storage, chunk_index_name=chunk_index_name,
                form=form, sketch=sketch, index_name=index_name)

        events = form.get('events')
        if not events:
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Unable to upload data, no file uploaded nor any events.')

        return self._upload_events(
            events=events, form=form, sketch=sketch, index_name=index_name)
def post ( self ) : upload_enabled = current_app . config [ 'UPLOAD_ENABLED' ] if not upload_enabled : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Upload not enabled' ) form = request . get_data ( parse_form_data = True ) if not form : form = request . form sketch_id = form . get ( 'sketch_id' , None ) if not sketch_id : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to upload data without supplying a ' 'sketch to associated it with.' ) if not isinstance ( sketch_id , int ) : sketch_id = int ( sketch_id ) sketch = Sketch . query . get_with_acl ( sketch_id ) if not sketch : abort ( HTTP_STATUS_CODE_NOT_FOUND , 'No sketch found with this ID.' ) if sketch . get_status . status == 'archived' : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to upload a file to an archived sketch.' ) if not sketch . has_permission ( current_user , 'write' ) : abort ( HTTP_STATUS_CODE_FORBIDDEN , 'Unable to upload data to a sketch, user does not have ' 'write access.' ) utils . update_sketch_last_activity ( sketch ) index_name = form . get ( 'index_name' , '' ) file_storage = request . files . get ( 'file' ) if file_storage : chunk_index_name = form . get ( 'chunk_index_name' , uuid . uuid4 ( ) . hex ) return self . _upload_file ( file_storage = file_storage , chunk_index_name = chunk_index_name , form = form , sketch = sketch , index_name = index_name ) events = form . get ( 'events' ) if not events : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to upload data, no file uploaded nor any events.' ) return self . _upload_events ( events = events , form = form , sketch = sketch , index_name = index_name )