Nyota Drive
Secure Sharing
Generating temporary, password-protected access links for private files.
If a file has private visibility, it cannot be accessed via a static URL. To distribute a private file securely, you must generate a Share.
Shares are distinct entities. A single file can have multiple active shares, each with different expiration times or passwords.
Creating a Share
const share = await drive.shares.create({
fileId: "file_abc123",
expiresInHours: 24, // Expires in 1 day
password: "secure_password", // Optional: Require a password to download
downloadAllowed: true, // Set to false for view-only (future support)
});
console.log(`Share Token: ${share.token}`);Resolving a Share (Client-Side)
You do not need an API key to resolve a share token!
The NyotaDrive class exposes a static resolveShare method. You can use this in your frontend application to exchange the share token for a short-lived S3 download URL.
import { NyotaDrive } from "@nyota/drive-sdk";
try {
const access = await NyotaDrive.resolveShare(
"the_share_token_string",
"secure_password", // Pass undefined if no password is required
);
// A temporary (15-minute) S3 presigned URL directly to the file
console.log(access.downloadUrl);
console.log(access.fileName);
} catch (error) {
console.error("Invalid token, expired, or wrong password.");
}Revoking Access
You can instantly destroy a share token, immediately cutting off access for anyone holding the link.
await drive.shares.revoke("share_xyz789");