Reference Client API
Client API
The client the drive and the hooks are built on, and
createMemoryClient answers the same, from the page. A refusal of the server is thrown as a RequestError with its status and code: name-taken, in-trash, over-quota, forbidden…On this page
Make one
import { createDriveClient } from '@rebofiles/drive'; // or @rebofiles/react
const client = createDriveClient({
base: '/api/files',
headers: async () => ({ authorization: `Bearer ${await token()}` }),
parallel: 3, // parts at once, of each file
retry: { attempts: 5, delay: 1000 }, // a part that fails, again
});
const { entries } = await client.list(null);
const file = await client.upload(input.files[0], { parent: entries[0].id, onProgress: ({ sent, size }) => draw(sent / size) });Reading
| Method | What it does |
|---|---|
| list(folder) | What is in a folder, or at the top with null, and the path down to it. |
| entry(id) | One entry, where it is, and whether it is in the trash. |
| recent() | The files changed last. |
| trash() | What is in one’s trash. |
| shared() | What others shared with the one asking. |
| sharedNew() | How many of those are new since they last looked. |
| search(query, { within, trashed }) | By name: every word, any case, with or without accents. |
| searchText(query) | By what is written in files, each with a piece of its text. |
| activity(id, limit?) | Who did what to an entry, and in a folder; the newest first. |
| usage() | The bytes one keeps, and how many one may. |
| starred() | What the one asking starred, the last starred first. |
| withField(name, value) | What has a field set to a value, of what one may read: the files of a client, of a case. |
Changing
| Method | What it does |
|---|---|
| createFolder(name, parent) | A folder; “(2)” when the name is taken. |
| rename(id, name, 'keep-both'?) | Refused when the name is taken there, unless both are kept. |
| move(id, parent, 'keep-both'?) | Into another folder, or to the top. |
| setColor(id, color | null) | A folder in one of the drive’s nine colours, or its own again. |
| copy(id, parent?) | A copy of a file, its bytes copied in the storage: beside it, or at one’s own top where one may not put it. |
| setFields(id, { name: value | null }) | Fields of your application on an entry, each to its text, or taken away with null. |
| star(id, starred?) | Starred by the one asking, or no longer with false: their own, seen by nobody else. |
| moveToTrash(id) | Into the trash, with what is inside it. |
| restore(id) | Out of the trash, back where it was. |
| deleteForever(id) | Gone, its bytes too. |
| emptyTrash() | One’s whole trash, gone. |
| restoreVersion(id, version) | An old version back, as a new one, without sending its bytes again. |
Uploads
| Method | What it does |
|---|---|
| upload(file, { parent, file, onProgress, signal, images, text, sha256 }) | A file in parts, resumed after a cut; file for a new version; its smaller pictures, placeholder and text sent after it. |
| duplicates(hashes) | The files with these bytes already, of what one may read. |
Sharing
| Method | What it does |
|---|---|
| share(id, who, role, days?) | With someone, or everyone signed in as *, as viewer, commenter or editor; for days, for good with null, as before unless said. |
| unshare(id, who) | No longer; anyone may leave what was shared with them. |
| people(query) | Who matches what is typed, people and groups, as the application finds them (people of the server). |
| names(ids) | How each of these is called, people and group: ids; one not known left out. |
| createLink(id, days, { password, once, uploads, request }) | A link to read it without signing in, and its token; of a folder, one that takes files too (also) or only (only); with request, the documents it asks for, a folder for each person and the names they are kept by. |
| updateLink(id, link, { days, uploads, request, closed }) | A link changed: for days from now, what it takes and asks; closed, or opened again. |
| linkToken(id, link) | The token of a link made before: the same every time. |
| removeLink(id, link) | Taken back. |
Requests
| Method | What it does |
|---|---|
| received() | What came through one’s requests for files, the newest first. |
| requests() | One’s requests for files: each folder, its link, its token and what came. |
| remind(id, link) | Whom a request was sent to, reminded now of what is missing, with the server’s reminders. |
| expiring(days?) | Files one may read whose field expires comes within so many days (15), or passed; the soonest first. |
| review(id, status, reason?) | A file that came accepted, or returned with a reason the sender’s page shows; looked at no more with null. |
Files
| Method | What it does |
|---|---|
| url(id, { version, inline, size }) | An address to read a file from: a download, or to show it at a size. |
| urls(ids, { inline, size }) | Those of many files at once, each with until when it is good. |
| pack(ids) | What an archive of some entries holds, for downloadZip. |
Settings
| Method | What it does |
|---|---|
| settings() | The drive’s settings, one’s own, and whether one may change the drive’s. |
| saveSettings(settings) | The drive’s, for whoever may configure it. |
| saveMySettings(mine) | One’s own language and theme. |
Live
| Method | What it does |
|---|---|
| watch(onChange, { onState }) | What anyone changes, as it happens: the folders and entries of each change one may see. Comes back by itself after a cut. Returns what stops it. |
Comments
| Method | What it does |
|---|---|
| comments(id) | What is said of an entry, each thread with its replies under it. |
| addComment(id, text, replyTo?) | A comment, or a reply under one; whom it names with @ are told. |
| editComment(id, comment, text) | What one’s own comment says. |
| resolveComment(id, comment, resolved?) | A thread dealt with, or open again. |
| removeComment(id, comment) | Taken back, with its replies: by its author, or the owner. |
Keeping
| Method | What it does |
|---|---|
| hold(id, reason?) | A legal hold: neither it nor what is in it trashed or deleted until released. For who may configure. |
| release(id) | The hold taken off. |
| exportPerson(user?) | Everything of a person, for a .zip: what they own, said and did. |
Told
| Method | What it does |
|---|---|
| notifications() | What the one asking was told (shared with them or a group of theirs, named in a comment), the newest first, and how many are new. |
| sawNotifications() | They looked: none is new any more. |
Looking after
| Method | What it does |
|---|---|
| adminUsage() | For who may configure: the files, folders and bytes of each person, and of the whole drive. |
| adminRequests() | For who may configure: every request for files open, whom it was sent to and what is still missing, to remind them. |
| adminActivity(limit?) | For who may configure: what was done anywhere in the drive, the newest first. |