-
Notifications
You must be signed in to change notification settings - Fork 3.2k
api share
Share endpoints allow sharing files with other users.
The /share endpoint shares 1 or more filesystem items
with one or more recipients. The recipients will receive
some notification about the shared item, making this
different from calling /grant-user-user with a permission.
When users are specified by email they will receive a share link.
Each item specified in the shares property is a tag-typed
object of type fs-share or app-share.
File shares grant permission to a file or directory. By default
this is read permission. If access is specified as "write",
then write permission will be granted.
App shares grant permission to read a protected app.
If there is a subdomain associated with the app, and the owner
of the subdomain is the same as the owner of the app, then
permission to access the subdomain will be granted.
Note that the subdomain is only associated if the subdomain
entry has associated_app_id set according to the app's id,
and will not be considered "associated" if only the index_url
happens to match the subdomain url.
If the app has shared_appdata set to true in its metadata
object, the recipient of the share will also get write permission
to the app owner's corresponding appdata directory. The appdata
directory must exist for this to work as expected
(otherwise the permission rewrite rule fails since the uuid
can't be determined).
{
"recipients": [
"user_that_gets_shared_to",
"[email protected]"
],
"shares": [
{
"$": "app-share",
"name": "some-app-name"
},
{
"$": "app-share",
"uid": "app-SOME-APP-UID"
},
{
"$": "fs-share",
"path": "/some/file/or/directory"
},
{
"$": "fs-share",
"path": "SOME-FILE-UUID"
}
]
}-
recipients - required
-
accepts:
string | Array<string> - description: recipients for the filesystem entries being shared.
-
notes:
- validation on
string: email or username - requirement of at least one value
- validation on
-
accepts:
-
shares: - required
-
accepts:
object | Array<object>- object is type-tagged
- type is either file-share or app-share
-
notes:
- requirement that file/directory or app exists
- requirement of at least one entry
-
accepts:
-
dry_run: - optional
-
accepts:
bool - description: when true, only validation will occur
-
accepts:
-
$:
api:share -
$version:
v0.0.0 -
status: one of:
"success","mixed","aborted" -
recipients: array of:
api:status-reportorheyputer:api/APIError -
paths: array of:
api:status-reportorheyputer:api/APIError -
dry_run:
trueif present
await fetch("http://puter.localhost:4100/share", {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${puter.authToken}`,
},
body: JSON.stringify({
recipients: [
"user_that_gets_shared_to",
"[email protected]"
],
shares: [
{
$: "app-share",
name: "some-app-name"
},
{
$: "app-share",
uid: "app-SOME-APP-UID"
},
{
$: "fs-share",
path: "/some/file/or/directory"
},
{
$: "fs-share",
path: "SOME-FILE-UUID"
}
]
}),
method: "POST",
});{
"$": "api:share",
"$version": "v0.0.0",
"status": "success",
"recipients": [
{
"$": "api:status-report",
"status": "success"
}
],
"paths": [
{
"$": "api:status-report",
"status": "success"
}
],
"dry_run": true
}{
"$": "api:share",
"$version": "v0.0.0",
"status": "mixed",
"recipients": [
{
"$": "api:status-report",
"status": "success"
}
],
"paths": [
{
"$": "heyputer:api/APIError",
"code": "subject_does_not_exist",
"message": "File or directory not found.",
"status": 404
}
],
"dry_run": true
}{
"$": "api:share",
"$version": "v0.0.0",
"status": "mixed",
"recipients": [
{
"$": "heyputer:api/APIError",
"code": "user_does_not_exist",
"message": "The user `non_existing_user` does not exist.",
"username": "non_existing_user",
"status": 422
}
],
"paths": [
{
"$": "api:status-report",
"status": "success"
}
],
"dry_run": true
}The /sharelink/check endpoint verifies that a token provided
by a share link is valid.
await fetch(`${config.api_origin}/sharelink/check`, {
"headers": {
"Content-Type": "application/json",
"Authorization": `Bearer ${puter.authToken}`,
},
"body": JSON.stringify({
token: '...',
}),
"method": "POST",
});-
token: - required
-
accepts:
stringThe token from the querystring parameter
-
accepts:
A type-tagged object, either of type api:share or api:error
{
"$": "api:share",
"uid": "836671d4-ac5d-4bd3-bc0a-ec357e0d8f02",
"email": "[email protected]"
}{
"$": "api:error",
"message":"Field `token` is required.",
"key":"token",
"code":"field_missing"
}The /sharelink/apply endpoint applies a share to the current
user if and only if that user's email is confirmed and matches
the email associated with the share.
await fetch(`${config.api_origin}/sharelink/apply`, {
"headers": {
"Content-Type": "application/json",
"Authorization": `Bearer ${puter.authToken}`,
},
"body": JSON.stringify({
uid: '836671d4-ac5d-4bd3-bc0a-ec357e0d8f02',
}),
"method": "POST",
});-
uid: - required
-
accepts:
stringThe uid of an existing share, received using/sharelink/check
-
accepts:
A type-tagged object, either of type api:status-report or api:error
{"$":"api:status-report","status":"success"}{
"message": "This share can not be applied to this user.",
"code": "can_not_apply_to_this_user"
}The /sharelink/request endpoint requests the permissions associated
with a share link to the issuer of the share (user that sent the share).
This can be used when a user is logged in, but that user's email does
not match the email associated with the share.
await fetch(`${config.api_origin}/sharelink/request`, {
"headers": {
"Content-Type": "application/json",
"Authorization": `Bearer ${puter.authToken}`,
},
"body": JSON.stringify({
uid: '836671d4-ac5d-4bd3-bc0a-ec357e0d8f02',
}),
"method": "POST",
});-
uid: - required
-
accepts:
stringThe uid of an existing share, received using/sharelink/check
-
accepts:
A type-tagged object, either of type api:status-report or api:error
{"$":"api:status-report","status":"success"}{
"message": "This share is already valid for this user; POST to /apply for access",
"code": "no_need_to_request"
}This wiki is generated from the repository. Do not edit files the wiki.
You are reading documentation for Puter, an open-source high-level operating system.
Getting started with Puter on localhost is as simple as:
git clone https://github.com/HeyPuter/puter.git
npm install
npm run start- Index (README.md)
- api drivers
- Group Endpoints
- Notification Endpoints
- Share Endpoints
- Type-Tagged Objects
- Comment Prefixes
- contributors vscode
- Local Email Testing
- Puter Extensions
- Repository Structure and Tooling
- Configuring Domains for Self-Hosted Puter
- Configuring Puter
- First Run Issues
- self_hosters config_values
- self_hosters support
- Self-Hosting Puter
- Backend Style
- Puter Backend - Directory Structure
- Puter Backend Boot Sequence
- Puter Kernel Moduels and Services
- Batch and Symlinks
- Metered Services and Cost Management
- Protected Apps and Subdomains
- Service Scripts
- Index (README.md)
- Configuring AI Services
- PuterAI API Request Examples
- src backend src modules puterai config
####### For Contributors