Sharing Files with other people
MaSH can make use of Foldr’s file sharing features to create public and secure links to files and folders on all your attached storage. Public links are accessible to all but can have an optional password for added security. Secure links are only accessible to select external delegates.
Sharing
A File’s sharing methods and properties are accessible via its sharing object.
Methods
createLink
createLink(Dictionary: ?properties)
Create a public link to a File object. The link will then be accessible via the File’s sharing.link property.
removeLink
removeLink()
Remove a public link from a File object.
The Link Object
Public links are attached to files via a Link object. To create a link we call the createLink method on the File’s sharing object.
Notes
Note that links will not be persisted until the
Link’ssavemethod is called.
Natural
set myFile to mash.files.get(12, "path/to/file.txt", "b8236683-6426-4658-bf6f-0e78068ca327")
# Create a link
myFile.sharing.createLink()
# The link will not be persisted until we call save
myFile.sharing.link.save()
printline myFile.sharing.link
Standard
myFile = mash.files.get(12, "path/to/file.txt", "b8236683-6426-4658-bf6f-0e78068ca327")
# Create a link
myFile.sharing.createLink()
# The link will not be persisted until we call save
myFile.sharing.link.save()
printline(myFile.sharing.link)
Output
Link {
"allow_uploads": false,
"delegates": [],
"description": "",
"expires": null,
"password": false,
"short_url": "ABCDE",
"slug": null,
"url": "https://demo.foldr.io/public/ABCDE"
}
Properties
allowUploads
allowUploads: boolean get/set
File N/A
Folder Allow delegates to upload to the shared folder.
delegates
delegates: array get/set
An array of email addresses which will be converted into external users who must sign in to access the shared item.
description: string get
A textual description that will be displayed in the browser above the shared item.
Notes
Your description can contain markdown content.
expires
expires: string|Date get/set
If the string “download” is passed then this link will expire as soon as it is downloaded. Alternatively a date object can be passed to expire the link at a particular time in the future. Pass null to disable expiration.
Notes
expiresapplies to the link and not each individual delegate. If you configure a link to expire on download and also add multiple delegates then the link will no longer be available once the first delegate has downloaded it.
password
password: boolean|string get/set
Require a password to access the link. The password should be set as a string but the property will always return a boolean indicating whether a password is set or not. Pass null to disable the password.
Notes
If delegates are specified then this setting is ignored as delegates will sign in with their own credentials.
shortUrl
shortUrl: string get
The short identifier for the shared item.
slug
slug: string get|set
A custom short URL to use for the link. Pass null to remove the slug.
Notes
The value that you pass will be “slugified”, that is all non-alphanumeric characters will be removed and spaces will be replaced with a hyphen. Duplicate slugs will be handled by appending a number, for example
a-custom-slug,a-custom-slug-1, etc.
### url
url: string get
The full public URL for this link.
Notes
You must have an external hostname configure on your Foldr appliance for this to be available.
Natural
set myFile to mash.files.get(12, "path/to/file.txt", "b8236683-6426-4658-bf6f-0e78068ca327")
# Create a link
myFile.sharing.createLink()
set file.sharing.link.delegates to ["[email protected]"]
set file.sharing.link.slug to "a custom url"
# The link will not be persisted until we call save
myFile.sharing.link.save()
printline myFile.sharing.link
Standard
myFile = mash.files.get(12, "path/to/file.txt", "b8236683-6426-4658-bf6f-0e78068ca327")
# Create a link
myFile.sharing.createLink()
file.sharing.link.delegates = ["[email protected]"]
file.sharing.link.slug = "a custom url"
# The link will not be persisted until we call save
myFile.sharing.link.save()
printline(myFile.sharing.link)
Output
Link {
"allow_uploads": false,
"delegates": [
"[email protected]"
],
"description": "",
"expires": null,
"password": false,
"short_url": "ABCDE",
"slug": "a-custom-url",
"url": "https://demo.foldr.io/flinks/a-custom-url"
}