Skip to main content

ChannelFileClient

ChannelFileClient: TypedEventEmitter<ChannelFileEvents> & object

Type declaration

create()

Parameters

ParameterType
requestChannelFileCreateRequest

Returns

Promise<ChannelFile>

Example

import {
ChannelFile,
ChannelFileCreateRequest,
ChannelGuid,
DirectoryGuid,
FileGuid,
rootServer,
} from "@rootsdk/server-app";

export async function createExample(
channelId: ChannelGuid,
directoryId: DirectoryGuid,
uploadToken: string
): Promise<ChannelFile> {
try {
// Set up the request
const request: ChannelFileCreateRequest = {
directoryId: directoryId,
channelId: channelId,
uploadTokenUri: uploadToken
};

// Call the API
const file: ChannelFile =
await rootServer.community.channelFiles.create(request);

return file;
} catch (error) {
// Detect error
throw error;
}
}

delete()

Parameters

ParameterType
requestChannelFileDeleteRequest

Returns

Promise<void>

Example

import {
ChannelFile,
ChannelFileDeleteRequest,
ChannelGuid,
DirectoryGuid,
FileGuid,
rootServer,
} from "@rootsdk/server-app";

export async function deleteExample(
channelId: ChannelGuid,
directoryId: DirectoryGuid,
fileId: FileGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelFileDeleteRequest = {
id: fileId,
directoryId: directoryId,
channelId: channelId,
};

// Call the API
await rootServer.community.channelFiles.delete(request);
} catch (error) {
// Detect error
throw error;
}
}

edit()

Parameters

ParameterType
requestChannelFileEditRequest

Returns

Promise<ChannelFileEditResponse>

Example

import {
ChannelFile,
ChannelFileEditRequest,
ChannelFileEditResponse,
ChannelGuid,
DirectoryGuid,
FileGuid,
rootServer,
} from "@rootsdk/server-app";

export async function editExample(
fileId: FileGuid,
channelId: ChannelGuid,
directoryId: DirectoryGuid,
name: string,
): Promise<ChannelFileEditResponse> {
try {
// Set up the request
const request: ChannelFileEditRequest = {
id: fileId,
channelId: channelId,
directoryId: directoryId,
name: "MyNewFileName",
};

// Call the API
const file: ChannelFileEditResponse =
await rootServer.community.channelFiles.edit(request);

return file;
} catch (error) {
// Detect error
throw error;
}
}

get()

Parameters

ParameterType
requestChannelFileGetRequest

Returns

Promise<ChannelFile>

Example

import {
ChannelFile,
ChannelFileGetRequest,
ChannelGuid,
DirectoryGuid,
FileGuid,
rootServer,
} from "@rootsdk/server-app";

export async function getExample(
fileId: FileGuid,
channelId: ChannelGuid,
directoryId: DirectoryGuid,
): Promise<ChannelFile> {
try {
// Set up the request
const request: ChannelFileGetRequest = {
id: fileId,
channelId: channelId,
directoryId: directoryId,
};

// Call the API
const response: ChannelFile =
await rootServer.community.channelFiles.get(request);

return response;
} catch (error) {
// Detect error
throw error;
}
}

list()

Parameters

ParameterType
requestChannelFileListRequest

Returns

Promise<ChannelFile[]>

Example

import {
ChannelFile,
ChannelFileListRequest,
ChannelGuid,
DirectoryGuid,
rootServer,
} from "@rootsdk/server-app";

export async function listExample(
channelId: ChannelGuid,
directoryId: DirectoryGuid,
): Promise<ChannelFile[]> {
try {
// Set up the request
const request: ChannelFileListRequest = {
channelId: channelId,
directoryId: directoryId,
};

// Call the API
const files: ChannelFile[] =
await rootServer.community.channelFiles.list(request);

return files;
} catch (error) {
// Detect error
throw error;
}
}

move()

Parameters

ParameterType
requestChannelFileMoveRequest

Returns

Promise<ChannelFileMoveResponse>

Example

import {
ChannelFile,
ChannelFileMoveRequest,
ChannelFileMoveResponse,
ChannelGuid,
DirectoryGuid,
FileGuid,
rootServer,
} from "@rootsdk/server-app";

export async function moveExample(
fileId: FileGuid,
channelId: ChannelGuid,
oldDirectoryId: DirectoryGuid,
newDirectoryId: DirectoryGuid,
): Promise<ChannelFileMoveResponse> {
try {
// Set up the request
const request: ChannelFileMoveRequest = {
id: fileId,
channelId: channelId,
oldDirectoryId: oldDirectoryId,
newDirectoryId: newDirectoryId,
};

// Call the API
const file: ChannelFileMoveResponse =
await rootServer.community.channelFiles.move(request);

return file;
} catch (error) {
// Detect error
throw error;
}
}

Parameters

ParameterType
requestChannelFileSearchRequest

Returns

Promise<ChannelFile[]>

Example

import {
ChannelFile,
ChannelFileSearchRequest,
ChannelGuid,
DirectoryGuid,
rootServer,
} from "@rootsdk/server-app";

export async function searchExample(
channelId: ChannelGuid,
search: string,
): Promise<ChannelFile[]> {
try {
// Set up the request
const request: ChannelFileSearchRequest = {
channelId: channelId,
search: search,
lastFileId: undefined,
};

// Call the API
const response: ChannelFile[] =
await rootServer.community.channelFiles.search(request);

return response;
} catch (error) {
// Detect error
throw error;
}
}

searchCommunity()

Parameters

ParameterType
requestChannelFileSearchCommunityRequest

Returns

Promise<ChannelFileSearchCommunityResponse>

Example

import {
ChannelFile,
ChannelFileSearchCommunityRequest,
ChannelFileSearchCommunityResponse,
ChannelGuid,
DirectoryGuid,
rootServer,
} from "@rootsdk/server-app";

export async function searchCommunityExample(
channelIds: ChannelGuid[],
search: string,
): Promise<ChannelFileSearchCommunityResponse> {
try {
// Set up the request
const request: ChannelFileSearchCommunityRequest = {
channelIds: channelIds,
search: search,
};

// Call the API
const response: ChannelFileSearchCommunityResponse =
await rootServer.community.channelFiles.searchCommunity(request);

return response;
} catch (error) {
// Detect error
throw error;
}
}