diff options
Diffstat (limited to 'doc/api/project_import_export.md')
-rw-r--r-- | doc/api/project_import_export.md | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/doc/api/project_import_export.md b/doc/api/project_import_export.md index 3f2cc09aa1e..635cb04e2e8 100644 --- a/doc/api/project_import_export.md +++ b/doc/api/project_import_export.md @@ -152,16 +152,14 @@ curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "path=a --form "file=@/path/to/file" "https://gitlab.example.com/api/v4/projects/import" ``` -cURL doesn't support posting a file from a remote server. Importing a project from a remote server can be accomplished through something like the following: +cURL doesn't support posting a file from a remote server. This example imports a project +using Python's `open` method: ```python import requests -from io import BytesIO - -s3_file = requests.get(presigned_url) url = 'https://gitlab.example.com/api/v4/projects/import' -files = {'file': ('file.tar.gz', BytesIO(s3_file.content))} +files = { "file": open("project_export.tar.gz", "rb") } data = { "path": "example-project", "namespace": "example-group" @@ -293,6 +291,27 @@ curl --request POST \ }' ``` +This example imports from an Amazon S3 bucket, using a module that connects to Amazon S3: + +```python +import requests +from io import BytesIO + +s3_file = requests.get(presigned_url) + +url = 'https://gitlab.example.com/api/v4/projects/import' +files = {'file': ('file.tar.gz', BytesIO(s3_file.content))} +data = { + "path": "example-project", + "namespace": "example-group" +} +headers = { + 'Private-Token': "<your_access_token>" +} + +requests.post(url, headers=headers, data=data, files=files) +``` + ```json { "id": 1, |