Repository navigation
Cloud
The Cloud module gives you full access to EcoleDirecte's personal cloud storage.
Let's fetch the contents of the student's personal cloud and traverse the folder structure.
import { Litedirecte } from "litedirecte";
const ld = new Litedirecte();
await ld.auth.login("your_username", "your_password");
// Retrieve the files and folders up to a depth of 3 folders deep
const cloudItems = await ld.cloud.getCloud({ depth: 3 });
console.log(`You have ${cloudItems.length} top-level files or folders.`);
cloudItems.forEach(item => {
if (item.type === "folder") {
console.log(`📁 Folder: ${item.libelle} (contains ${item.children?.length ?? 0} items)`);
} else {
console.log(`📄 File: ${item.libelle} (${(item.taille / 1024).toFixed(1)} KB)`);
}
});Fetches all files and folders available in the student's personal space.
ld.cloud.getCloud(options?: GetCloudOptions): Promise<CloudEntry[]>-
options(optional):-
depth(number): How many folders deep the SDK should scan and build children arrays for. Defaults to3. Must be an integer between 1 and 10, otherwise anEdValidationErroris thrown and nothing is requested.
-
Creates a new folder under a parent directory.
ld.cloud.createFolder(
name: string,
parentNode: CloudNode,
): Promise<CloudNode>-
name(string): The name for your new folder. -
parentNode(CloudNode): The folder node where your new folder should be created.
import { Litedirecte } from "litedirecte";
const ld = new Litedirecte();
await ld.auth.login("your_username", "your_password");
const tree = await ld.cloud.getCloud();
const myParentFolder = tree.find(node => node.type === "folder" && node.libelle === "My Documents");
if (myParentFolder) {
const newFolder = await ld.cloud.createFolder("Math Homework", myParentFolder);
console.log(`Successfully created folder: ${newFolder.libelle}`);
}Moves files or folders to the Recycle Bin / Trash.
ld.cloud.deleteNodes(
nodes: CloudNode[],
): Promise<{ success: boolean }>-
nodes(CloudNode[]): An array of file or folder nodes to delete.
import { Litedirecte } from "litedirecte";
const ld = new Litedirecte();
await ld.auth.login("your_username", "your_password");
const tree = await ld.cloud.getCloud();
const oldFile = tree.find(node => node.type === "file" && node.libelle === "temporary_draft.txt");
if (oldFile) {
const result = await ld.cloud.deleteNodes([oldFile]);
if (result.success) {
console.log("File successfully moved to trash!");
}
}Uploads a file to a parent folder in the cloud (POST /televersement.awp?verbe=post&mode=CLOUD&dest=..., multipart field file).
ld.cloud.uploadFile(
file: Blob,
parentNode: CloudNode,
filename?: string,
options?: UploadCloudFileOptions,
): Promise<CloudNode>-
file(Blob): The file or blob to upload. -
parentNode(CloudNode): The destination folder node where the file should be uploaded. -
filename(string, optional): Custom filename. Defaults tofile.nameiffileis aFileinstance. -
options(UploadCloudFileOptions, optional):-
mockMode(boolean): Run in mock mode.
-
import { Litedirecte } from "litedirecte";
const ld = new Litedirecte();
await ld.auth.login("your_username", "your_password");
const tree = await ld.cloud.getCloud();
const folder = tree.find(node => node.type === "folder" && node.libelle === "Documents");
if (folder) {
const file = new File(["Hello world"], "hello.txt");
const uploaded = await ld.cloud.uploadFile(file, folder);
console.log(`Successfully uploaded: ${uploaded.libelle} (${uploaded.taille} bytes)`);
}Creates and uploads a plain-text file to a parent folder in the cloud.
ld.cloud.uploadTextFile(
content: string,
filename: string,
parentNode: CloudNode,
options?: UploadCloudFileOptions,
): Promise<CloudNode>const fileNode = await ld.cloud.createTextFile("Hello, World!", "notes.txt", folder);Updates (overwrites) an existing text file in the cloud with new text content.
ld.cloud.updateTextFile(
content: string,
fileNode: CloudFileNode,
options?: UploadCloudFileOptions,
): Promise<CloudNode>const updatedNode = await ld.cloud.editTextFile("Updated note content!", fileNode);Represents either a folder or a file inside the EcoleDirecte cloud:
interface CloudNode {
id: string; // Unique string ID of the file or folder
type: "file" | "folder"; // Node type
libelle: string; // Name of the file or folder (raw key)
date: string; // Date string when created or updated
taille: number; // File size in bytes (raw key)
readonly: boolean; // True if the node is write-protected (raw key)
hidden: boolean; // True if the item is hidden (raw key)
isTrash: boolean; // True if the item is currently in the trash
isLoaded?: boolean; // Indicates if subfolders have been loaded
quota?: number; // Space limit in bytes (usually present on top folder)
displayText?: string; // Friendly display string
children?: CloudNode[]; // Child nodes (if a folder)
proprietaire?: { // Owner metadata object (raw key)
id: number;
type: string;
nom: string;
prenom: string;
particule: string;
};
}A simple union representing the entries returned:
type CloudEntry = CloudFolderNode | CloudFileNode;
interface CloudFolderNode extends CloudNode {
type: "folder";
children: CloudNode[];
}
interface CloudFileNode extends CloudNode {
type: "file";
}getCloud() at the default depth is maintained; other depths are manual entries. Reads accept { force: true } to skip the cache. See Cache & sync.
© 2026 typeof (Scolup) | Licensed under AGPL 3.0