-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Davis
committed
Mar 4, 2019
1 parent
14f4be9
commit 895d6bd
Showing
13 changed files
with
170 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,35 @@ | ||
Upload and Publish | ||
================== | ||
|
||
Chunked Uploads | ||
--------------- | ||
|
||
For large file uploads, Pulp supports uploading files in chunks. To begin uploading a file in | ||
chunks, an initial PUT request must be sent to the ``/pulp/api/v3/uploads`` endpoint:: | ||
|
||
http --form PUT :8000/pulp/api/v3/uploads/ file@./chunkaa 'Content-Range:bytes 0-6291455/32095676' | ||
|
||
This returns an upload href (e.g. ``/pulp/api/v3/uploads/a8b5a7f7-2f22-460d-ab20-d5616cb71cdd/``) that can | ||
be used for subsequent chunks:: | ||
|
||
http --form PUT :8000/pulp/api/v3/uploads/a8b5a7f7-2f22-460d-ab20-d5616cb71cdd/ file@./chunkbb 'Content-Range:bytes 6291456-10485759/32095676' | ||
|
||
Once all chunks have been uploaded, a final POST request with the file md5 can be sent to complete the | ||
upload:: | ||
|
||
http POST :8000/pulp/api/v3/uploads/a8b5a7f7-2f22-460d-ab20-d5616cb71cdd/ md5=037a47d93670e64f2b1038e6f90e4cfd | ||
|
||
Then the artifact may be created with the upload href:: | ||
|
||
http POST :8000/pulp/api/v3/artifacts/ upload=/pulp/api/v3/uploads/a8b5a7f7-2f22-460d-ab20-d5616cb71cdd/ | ||
|
||
Note that after creating an artifact from an upload, the upload gets deleted and cannot be re-used. | ||
|
||
Putting this altogether, here is an example that uploads a 1.iso file in two chunks:: | ||
|
||
curl -O https://repos.fedorapeople.org/repos/pulp/pulp/fixtures/file-large/1.iso | ||
split --bytes=6M 1.iso chunk | ||
export UPLOAD=$(http --form PUT :8000/pulp/api/v3/uploads/ file@./chunkaa 'Content-Range:bytes 0-6291455/32095676' | jq -r '._href') | ||
http --form PUT :8000$UPLOAD file@./chunkab 'Content-Range:bytes 6291456-10485759/32095676' | ||
http POST :8000$UPLOAD md5=037a47d93670e64f2b1038e6f90e4cfd | ||
http POST :8000/pulp/api/v3/artifacts/ upload=$UPLOAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Generated by Django 2.1.7 on 2019-02-28 11:57 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import drf_chunked_upload.models | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('pulp_app', '0003_repositoryversioncontentdetails'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Upload', | ||
fields=[ | ||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
('file', models.FileField(max_length=255, null=True, upload_to=drf_chunked_upload.models.generate_filename)), | ||
('filename', models.CharField(max_length=255)), | ||
('offset', models.BigIntegerField(default=0)), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('status', models.PositiveSmallIntegerField(choices=[(1, 'Incomplete'), (2, 'Complete')], default=1)), | ||
('completed_at', models.DateTimeField(blank=True, null=True)), | ||
('user', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='upload', to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .orphans import OrphansView # noqa | ||
from .status import StatusView # noqa | ||
from .upload import UploadView # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from drf_chunked_upload.views import ChunkedUploadView | ||
from pulpcore.app.models import Upload | ||
from pulpcore.app.serializers import UploadSerializer | ||
|
||
|
||
class UploadView(ChunkedUploadView): | ||
"""View for chunked uploads.""" | ||
model = Upload | ||
serializer_class = UploadSerializer | ||
queryset = Upload.objects.all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters