Space SDK Package

Space SDK Package

  • Users
  • Storage
  • Space Docs

›Storage API

Getting Started

  • Default Implementations

Users API

  • Users class
  • SpaceUser interface

Storage API

  • UserStorage class
  • IdentityStorage interface
  • BrowserStorage class
  • FileStorage class

@spacehq/sdk > UserStorage

UserStorage class

UserStorage performs storage actions on behalf of the user provided.

Signature:

export declare class UserStorage 

Example

const spaceStorage = new UserStorage(spaceUser);

// create an empty folder
await spaceStorage.createFolder({
  bucket: 'personal',
  path: '/cool'
});

Constructors

ConstructorModifiersDescription
(constructor)(user, config)Constructs a new instance of the UserStorage class

Methods

MethodModifiersDescription
addItems(request)addItems is used to upload files to buckets.It uses an ReadableStream of Uint8Array data to read each files content to be uploaded.Uploads will sequential and asynchronous with updates being delivered through the event emitter returned by the function.
createFolder(request)Creates an empty folder at the requested path and bucket.
getFilesSharedByMe(offset)Return the list of files the current storage user has shared with other users in the past
getFilesSharedWithMe(offset)Return the list of shared files accepted by user
getNotifications(seek, limit)Returns notifications for the user. If the notification is detected to be a supported type, it is enhanced with additional information stored in the relatedObject field.
getRecentlySharedWith(offset)Returns a list of public keys of clients to which files where shared with
handleFileInvitation(invitationId, accept)
initListener()Creates the listener post constructor
initMailbox()Setup mailbox
listDirectory(request)Returns all bucket entries at the specified path.
movePaths(bucketName, sourcePaths, destPaths)Moves files in a given bucket from source to destination. Multiple moves can be requested by matching up the indices of the sourcePath and destPath arrays
notificationSubscribe()NotificationSubscribe is used to listen for Mailbox events.It listens to the users mailbox events, enriches the message with Space specific data.
openFile(request)openFile returns a stream (AsyncIterableIterator) of the file at the path in the bucket.
openFileByUuid(request)Open a file with uuid. Will only return a result if the current user has access to the file.See the sharing guide for a use case of how this method will be useful.
setFilePublicAccess(request)Allow or revoke public access to a file.
setNotificationsLastSeenAt(timestamp)setNotificationsLastSeenAt sets the field so that .
shareViaPublicKey(request)shareViaPublicKey shares specified files to users who owns the specified public keys.
syncFromTempKey(key)Sync the notifications from the temp key with the current space user of this storage.This is useful for new users who have some pending invitation assigned to the notification.
txlSubscribe()txlSubscribe is used to listen for Textile events.It listens to all buckets for the user and produces an event when something changes in the bucket.TODO: try to make the event more granular so we can pick up specific files/folders
← SpaceUser interfaceIdentityStorage interface →
  • UserStorage class
  • Example
  • Constructors
  • Methods
Space SDK Package
Docs
Getting StartedUsersStorage
Resources
All DocumentationProject SlackBlog
More
GitHubStar
Follow @spacestorage