/v2/files/{file_id}/actions/copy
This call copies the specified file to a new project. Files retain their metadata when copied, but may be assigned new names in their target project.
Note that Controlled Data files may not be copied to Open Data projects. To make this call, you should have copy permission within the project you are copying from.
https://api.sb.biodatacatalyst.nhlbi.nih.gov/v2/files/{file_id}/actions/copy
file_ids
Recall from the API Overview that the
file_id
is a hexadecimal string.You can get the
file_id
for an file by making the call to list files within a specified project (primary method)
Request
Example request
POST v2/files/567890abc9b0307bc0414164/actions/copy HTTP/1.1
Host: api.sb.biodatacatalyst.nhlbi.nih.gov
X-SBG-Auth-Token: 3259c50e1ac5426ea8f1273259740f74
curl --data '{"project": "RFranklin/my-project", "name": "new-file"}' -s -H "X-SBG-Auth-Token: 7942f56901534434a054dafc3813bc96" -H "content-type: application/json" -X POST "https://api.sb.biodatacatalyst.nhlbi.nih.gov/v2/files/567890abc9b0307bc0414164/actions/copy"
Header Fields
Name | Description |
---|---|
X-SBG-Auth-Token required | Your authentication token. |
Path parameters
Name | Description |
---|---|
file_id | The ID for the file you are querying. It can be obtained by making the call to list your files (primary method). |
Query parameters
Name | Data type | Description |
---|---|---|
fields | string | Selector specifying a subset of fields to include in the response. |
Request body
The body should contain the following key-value pairs:
Key | Datatype of value | Description of value |
---|---|---|
"project" required | string | The name of the project you want to copy the file to |
"name" | string | The new name the file will have in the target project. If its name will not change, omit this key. |
Example request body
{
"project": "RFranklin/my-project",
"name": "new-file"
}
Response
See a list of response codes that may be contained in the body of the response.
Example response body
The response gives the full specification of the file, and its metadata.
{
"href": "https://api.sb.biodatacatalyst.nhlbi.nih.gov/v2/files/567890abc1e5339df0414123",
"id": "567890abc1e5339df0414123",
"name": "new-file",
"size": 5,
"project": "rfranklin/my-project",
"parent": "567890abc3d8130ea4047731",
"type": "file",
"created_on": "2019-10-10T10:44:13Z",
"modified_on": "2019-10-10T10:44:13Z",
"storage": {
"type": "PLATFORM",
"hosted_on_locations": [
"aws:us-east-1",
"google:us-west1"
]
},
"origin": {},
"tags": [
"TEST"
],
"metadata": {
"md5_sum": "3feb601b4b5563db86669175f921463b",
"sbg_public_files_category": "reference"
}
}