From a68ea57d619f02b10e605cc39448b136e651d2db Mon Sep 17 00:00:00 2001 From: Michael Leopard Date: Tue, 10 Jul 2018 13:55:56 +0000 Subject: Update project_import_export.md to include example remote import script and additional curl command --- doc/api/project_import_export.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/doc/api/project_import_export.md b/doc/api/project_import_export.md index 085437c801a..1d307df4d0f 100644 --- a/doc/api/project_import_export.md +++ b/doc/api/project_import_export.md @@ -32,6 +32,14 @@ POST /projects/:id/export curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/1/export --data "description=FooBar&upload[http_method]=PUT&upload[url]=https://example-bucket.s3.eu-west-3.amazonaws.com/backup?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIMBJHN2O62W8IELQ%2F20180312%2Feu-west-3%2Fs3%2Faws4_request&X-Amz-Date=20180312T110328Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=8413facb20ff33a49a147a0b4abcff4c8487cc33ee1f7e450c46e8f695569dbd" ``` +Some systems may require the upload url to be url-encoded: + +```console +curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/1/export \ + --data "upload[http_method]=PUT" \ + --data-urlencode "upload[url]=https://example-bucket.s3.eu-west-3.amazonaws.com/backup?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIMBJHN2O62W8IELQ%2F20180312%2Feu-west-3%2Fs3%2Faws4_request&X-Amz-Date=20180312T110328Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=8413facb20ff33a49a147a0b4abcff4c8487cc33ee1f7e450c46e8f695569dbd" +``` + ```json { "message": "202 Accepted" @@ -125,6 +133,29 @@ by `@`. For example: curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "path=api-project" --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: + +```python +import requests +import urllib +import json +import sys + +s3_file = urllib.urlopen(presigned_url) + +url = 'https://gitlab.example.com/api/v4/projects/import' +files = {'file': s3_file} +data = { + "path": "example-project", + "namespace": "example-group" +} +headers = { + 'Private-Token': "9koXpg98eAheJpvBs5tK" +} + +requests.post(url, headers=headers, data=data, files=files) +``` + ```json { "id": 1, -- cgit v1.2.1 From 491afd39a0c5aae1d8626cb25fd5d05be75fa416 Mon Sep 17 00:00:00 2001 From: Michael Leopard Date: Tue, 10 Jul 2018 15:27:10 +0000 Subject: Update project_import_export.md. Removed cURL statement --- doc/api/project_import_export.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/api/project_import_export.md b/doc/api/project_import_export.md index 1d307df4d0f..83e405141f1 100644 --- a/doc/api/project_import_export.md +++ b/doc/api/project_import_export.md @@ -28,11 +28,6 @@ POST /projects/:id/export | `upload[url]` | string | yes | The URL to upload the project | | `upload[http_method]` | string | no | The HTTP method to upload the exported project. Only `PUT` and `POST` methods allowed. Default is `PUT` | -```console -curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/1/export --data "description=FooBar&upload[http_method]=PUT&upload[url]=https://example-bucket.s3.eu-west-3.amazonaws.com/backup?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIMBJHN2O62W8IELQ%2F20180312%2Feu-west-3%2Fs3%2Faws4_request&X-Amz-Date=20180312T110328Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=8413facb20ff33a49a147a0b4abcff4c8487cc33ee1f7e450c46e8f695569dbd" -``` - -Some systems may require the upload url to be url-encoded: ```console curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/1/export \ -- cgit v1.2.1