Copy multiple files between projects

/action/files/copy

For general information on the API, including formatting, parameters, and pagination, please see the API Overview.

This call allows you to copy files between projects. Unlike the call to copy a file between projects, this call lets you batch the copy operation and copy a list of files at a time.

👍

File IDs

Note that a file's ID is dependent on the project it is contained in. So, when you copy files from one project to another, their IDs will be different in the target project.

The file names, however, do not change by copying, except where copying would yield non-unique file names in a project. For details of this use case, see the tipbox at the bottom of the page.

https://cavatica-api.sbgenomics.com/v2/action/files/copy

Files are specified by their IDs, which you can obtain by making the API call to list all files accessible to you.

Request

Example request

POST /v2/action/files/copy HTTP/1.1
Host: cavatica-api.sbgenomics.com
X-SBG-Auth-Token: 7942f56901534434a054dafc3813bc96
curl --data '{"project": "RFranklin/my-project", "file_ids": ["567890abc4f3066bc3750174", "567890abc1e5339df0414123"]}' -s -H "X-SBG-Auth-Token: 7942f56901534434a054dafc3813bc96" -H "content-type: application/json" -X POST "https://cavatica-api.sbgenomics.com/v2/action/files/copy"

Request body

In the body, you should enter a list of key-value pairs. The keys, and the values they take, are described in the following table.

KeyData type of valueContent of value
projectstringThe name of the project you want to copy into.
file_idsa list of stringsThe IDs of the files you want to copy.

Example request body

{
	"project": "RFranklin/my-project",
	"file_ids": ["567890abc4f3066bc3750174", "567890abc1e5339df0414123"]

}

Header Fields

NameDescription
X-SBG-Auth-Token
required
Your CAVATICA authentication token.

Query parameters

N/A

Response

See a list of CAVATICA-specific response codes that may be contained in the body of the response.

Example response body

{
  "5655df71e4b08c5d86970945": {
    "status": "OK",
    "new_file_id": "567890abc4f3066bc3750174",
    "new_file_name": "sorted.bam"
  }
}

👍

Interpreting the request body

The request returns an object "new_file_name" for every file copied.

The "new_file_name" will be the same as the file's old name in all cases except for the case in which you already have a file with that name in the target project. If an identically-named file exists in the project, then the copied file will be automatically renamed by prefixing it with an increment of 1. For instance, if I copy the file named file.ext to my project, and there already exists a file.ext there, then my incoming file will be renamed 1_file.ext.

It is not possible to re-name files other than by this automatic procedure with this call. If you want to copy and rename a file, use the alternative (non-batch) call to copy a file. This restriction optimizes the batch request: it adds 100ms per file to rename it during copying, so if copying 100 files, it would take 10s longer to rename all of them.

Related API requests

  • Copy a file : this call allows you finer control over the metadata, while this current request allows you to batch.

Language