@spacehq/sdk > UserStorage > openFileByUuid
UserStorage.openFileByUuid() method
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.
Signature:
openFileByUuid(request: OpenUuidFileRequest): Promise<OpenUuidFileResponse>;
Parameters
Parameter | Type | Description |
---|---|---|
request | OpenUuidFileRequest |
Returns:
Promise<OpenUuidFileResponse>
Example
const spaceStorage = new UserStorage(spaceUser);
const response = await spaceStorage.openFileByUuid({
uuid: 'file-uu-id',
});
const filename = response.entry.name;
// response.stream is an async iterable
for await (const chunk of response.stream) {
// aggregate the chunks based on your logic
}
// response also contains a convenience function consumeStream
const fileBytes = await response.consumeStream();