Example #1
0
    def post(self):
        job_id = g.token['job']['id']

        j = g.db.execute_one_dict(
            '''
            SELECT id
            FROM job
            WHERE id = %s
            AND (state = 'running' OR end_date > NOW() - INTERVAL '5 minutes')
        ''', [job_id])

        if not j:
            abort(401, 'Unauthorized')

        for f in request.files:
            stream = request.files[f].stream
            key = '%s/%s' % (job_id, f)
            storage.upload_archive(stream, key)
            size = stream.tell()

            archive = {'filename': f, 'size': size}

            g.db.execute(
                '''
                UPDATE job
                SET archive = archive || %s::jsonb
                WHERE id = %s
            ''', [json.dumps(archive), job_id])

        g.db.commit()

        return jsonify({"message": "File uploaded"})
Example #2
0
    def post(self):
        job_id = g.token['job']['id']

        for f in request.files:
            stream = request.files[f].stream
            key = '%s/%s' % (job_id, f)
            storage.upload_archive(stream, key)
            size = stream.tell()

            archive = {'filename': f, 'size': size}

            g.db.execute(
                '''
                UPDATE job
                SET archive = archive || %s::jsonb
                WHERE id = %s
            ''', [json.dumps(archive), job_id])

        g.db.commit()

        return jsonify({"message": "File uploaded"})