Clone a File

Clones a file.

When you clone a file, you create a new file that is a duplicate of original file, including its history and version information, but that has a different name. This new file exists completely independent of the source file.

Note: For more information about this command, including descriptions of any path and request parameters, request body schema, response codes and schemas, and payload examples, refer to the online API reference for this command at the following web page:

Clone a file

URI

https://bartendercloud.com/api/librarian/files/{fileId}/clone

Note: The bartendercloud.com domain that is referenced in the URI and in the code example that follows must be replaced with the contents of the DataCenterURI claim that is extracted from your access token. For more information, refer to Extracting the DataCenterURI Claim.

Path Parameters

fileId

Type: String

Specifies the ID of the file to clone. Required.

Query Parameters

None.

Example

Request body: See FileCloneRequest.

Response: See File.

Copy
// Assume that the stream is of the System.IO.Stream type and references the file content to upload.
// Assume that fileId is the ID of the target file. 
// Assume that destinationFolderId is the ID of the folder that will receive the new cloned file.
var cloneRequest = new FileCloneRequest() {
   FileName = "Cloned SQL File",
   DestinationFolderId = detinationFolderId
};
var client = new HttpClient();

HttpRequestMessage request = new HttpRequestMessage
{
   RequestUri = new Uri($"https://bartendercloud.com/api/librarian/files/{fileId}/clone"),
   Content = new StringContent(JsonConvert.SerializeObject(cloneRequest), Encoding.UTF8, "application/json"),
   Method = HttpMethod.Post
};

HttpResponseMessage msg = await client.SendAsync(request);

if (msg.IsSuccessStatusCode)
{
   return JsonConvert.DeserializeObject<File>(await msg.Content.ReadAsStringAsync());
}