summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTom Catshoek <tomcatshoek@zeelandnet.nl>2022-06-26 08:29:13 +0200
committerGitHub <noreply@github.com>2022-06-26 08:29:13 +0200
commitb6447211754e126f64e12fc735ad74fe557b7fb4 (patch)
tree2c86425ce6b25b4d40bf0c12aa0d1f7def77838c /docs
parent0f2a602d3a9d6579f5fdfdf945a236ae44e93a12 (diff)
downloadgitlab-b6447211754e126f64e12fc735ad74fe557b7fb4.tar.gz
feat(downloads): allow streaming downloads access to response iterator (#1956)
* feat(downloads): allow streaming downloads access to response iterator Allow access to the underlying response iterator when downloading in streaming mode by specifying `iterator=True`. Update type annotations to support this change. * docs(api-docs): add iterator example to artifact download Document the usage of the `iterator=True` option when downloading artifacts * test(packages): add tests for streaming downloads
Diffstat (limited to 'docs')
-rw-r--r--docs/gl_objects/pipelines_and_jobs.rst13
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/gl_objects/pipelines_and_jobs.rst b/docs/gl_objects/pipelines_and_jobs.rst
index a05d968..f0bdd3a 100644
--- a/docs/gl_objects/pipelines_and_jobs.rst
+++ b/docs/gl_objects/pipelines_and_jobs.rst
@@ -274,6 +274,19 @@ You can also directly stream the output into a file, and unzip it afterwards::
subprocess.run(["unzip", "-bo", zipfn])
os.unlink(zipfn)
+Or, you can also use the underlying response iterator directly::
+
+ artifact_bytes_iterator = build_or_job.artifacts(iterator=True)
+
+This can be used with frameworks that expect an iterator (such as FastAPI/Starlette's
+``StreamingResponse``) to forward a download from GitLab without having to download
+the entire content server-side first::
+
+ @app.get("/download_artifact")
+ def download_artifact():
+ artifact_bytes_iterator = build_or_job.artifacts(iterator=True)
+ return StreamingResponse(artifact_bytes_iterator, media_type="application/zip")
+
Delete all artifacts of a project that can be deleted::
project.artifacts.delete()