Chunk uploading: implement properly using a custom Parser.
parent
11001ed62c
commit
1d5baece1e
@ -0,0 +1,17 @@
|
||||
# Generated by Django 3.0.3 on 2020-08-04 10:59
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('django_etebase', '0021_auto_20200626_0913'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='collectionitemchunk',
|
||||
unique_together={('item', 'uid')},
|
||||
),
|
||||
]
|
@ -0,0 +1,15 @@
|
||||
from rest_framework.parsers import FileUploadParser
|
||||
|
||||
|
||||
class ChunkUploadParser(FileUploadParser):
|
||||
"""
|
||||
Parser for chunk upload data.
|
||||
"""
|
||||
media_type = 'application/octet-stream'
|
||||
|
||||
def get_filename(self, stream, media_type, parser_context):
|
||||
"""
|
||||
Detects the uploaded file name.
|
||||
"""
|
||||
view = parser_context['view']
|
||||
return parser_context['kwargs'][view.lookup_field]
|
Loading…
Reference in New Issue