Add a Temporary File by Path

Creates a temporary file in a specified location in Librarian. The location is specified by the file path.

Librarian supports the creation of temporary files. These temporary files do not have to be associated with the $temp space; they can exist anywhere in the Main space as well.

The purpose of this API is to reduce the number of calls that are needed to create a temporary file. Without this API, you must first verify that the name of the proposed temporary file is unique and then create the actual temporary file. By using the Add a Temporary File by Path endpoints, you can create an empty temporary file with a single call.

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:

Add a temporary file by path

URI

https://bartendercloud.com/api/librarian/files/tempfile/path/{folderPath}

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

folderPath

Type: String

Specifies the path of the requested folder. Required.

Comment: The {folderPath} parameter must be single-URL encoded, and the path must start with the "librarian://{spaceName}/" prefix. Replace {spaceName} with the name of the target space (such as Main or $temp).

For example, the actual path for the "My Folder" folder in the Main space is as follows: 

librarian://Main/My Folder/

The URL-encoded {folderPath} parameter is as follows:

librarian%3A%2F%2FMain%2FMy%20Folder%2F

The full URI would resemble the following: 

https://bartendercloud.com/api/librarian/files/tempfile/path/librarian%3A%2F%2FMain%2FMy%20Folder%2F

Query Parameters

None.

Example

Request body: See TempFileAddByPathRequest.

Response: See FileChange.

Copy

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");

var addTempFileRequest = new TempFileAddByPathRequest() {
    Comment = "Creating a new temporary file",
    FileContentType = "txt",
    Encryption = "",    // Not encrypted.
    InheritFromFolderPermissions = true,
    Metadata = null,
    Permissions = null,    // Permissions are inherited from the containing folder.
    IsHidden = false,
    Prefix = "Tmp"        // The generated file name will have a 'Tmp' prefix.
    Extension = "txt"     // The generated file name will have a '.txt' file name extension.
};

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

HttpResponseMessage msg = await client.SendAsync(request);

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