seaweed_volume: Seaweed Volume API

Description Methods

Description

Create a seaweed_volume object for interacting with a SeaweedFS volume

See https://github.com/chrislusf/seaweedfs/wiki/Volume-Server-API for details

Methods

Public methods


Method new()

Create client object for sending http requests to seaweed volume

Usage
seaweed_volume$new(seaweed_url)
Arguments
seaweed_url

Root URL of Seaweed volume

Returns

A new seaweed_volume object


Method upload_file()

Upload a file to SeaweedFS.

Usage
seaweed_volume$upload_file(fid, path)
Arguments
fid

The file ID from SeaweedFS. See seaweed_master$assign() to get a file ID. Or use seaweed_master$upload_file() to upload directly.

path

Path to file to upload

Returns

Size of uploaded file


Method upload_object()

Upload an arbitrary R object to SeaweedFS.

This serializes R object to raw vector of bytes and then saves bytes to SeaweedFS. To recover R object as saved use seaweed_volume$download_object()

Usage
seaweed_volume$upload_object(fid, object)
Arguments
fid

The file ID from SeaweedFS. See seaweed_master$assign() to get a file ID. Or use seaweed_master$upload_file() to upload directly.

object

The object to upload

Returns

Size of uploaded object


Method upload_raw()

Upload vector of raw bytes to SeaweedFS.

Usage
seaweed_volume$upload_raw(fid, raw)
Arguments
fid

The file ID from SeaweedFS. See seaweed_master$assign() to get a file ID. Or use seaweed_master$upload_file() to upload directly.

raw

The object to upload

Returns

Size of uploaded object


Method read()

Read file from SeaweedFS into R

Usage
seaweed_volume$read(fid)
Arguments
fid

SeaweedFS file ID to read

Returns

The file contents


Method download_file()

Download file from SeaweedFS to a local path.

If called with an fid matching an R object uploaded via seaweed_volume$upload_object() then this will download raw bytes from SeaweedFS which can be converted back to R object at later point using unserialize or readRDS.

Usage
seaweed_volume$download_file(fid, path = tempfile())
Arguments
fid

SeaweedFS file ID to download

path

Local file path to save to

Returns

The file path written to


Method download_object()

Download and deserialize R object from SeaweedFS

If data downloaded from SeaweedFS is not unserializable (i.e. it was written using seaweed_volume$upload_file()) then this will throw an error. See seaweed_volume$download_file() to download as a file.

Usage
seaweed_volume$download_object(fid)
Arguments
fid

SeaweedFS file ID to download

Returns

The deserialized object


Method download_raw()

Download raw bytes from SeaweedFS

Usage
seaweed_volume$download_raw(fid)
Arguments
fid

SeaweedFS file ID to download

Returns

The raw bytes


Method delete()

Delete a file from SeaweedFS

Usage
seaweed_volume$delete(fid)
Arguments
fid

SeaweedFS file ID to delete

Returns

Nothing, called for side effects


mrc-ide/kelp documentation built on Dec. 21, 2021, 10:04 p.m.