Skip to content

Plugin for cabal clients for message file attachments shared via dat

Notifications You must be signed in to change notification settings

cabal-club/cabal-client-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cabal Files [WIP]

Plugin for cabal clients for message file attachments shared via dat

Example

import CabalFiles from 'cabal-client-files'


## Init and set path to store dats for the cabal

cabalFiles = CabalFiles({
  storagePath: FILES_DIR + '/' + cabal.key + '/'
})


## Publish a file message

var path = [local filesystem path to file]
var datKey = await cabalFiles.getDatKeyFromStoragePath(userKey)
let publishData = await cabalFiles.publish({ datKey, name, path, userKey: user.key })
cabal.publish({
  type: 'chat/file',
  content: {
    channel,
    text: text || 'dat://' + publishData.datKey + '/' + publishData.datFileName,
    file: { key: publishData.datKey, name: publishData.datFileName, size, type }
  }
})


## Swarm and download and get path to local dat file from a cabal message

let datData = await cabalFiles.fetch({
  datKey: message.value.content.file.key,
  fileName: message.value.content.file.name,
  userKey: message.key
})


## Seed your files

cabalFiles.getDatKeyFromStoragePath(user.key).then((datKey) => {
  if (datKey) {
    cabalFiles.currentUserFilesDatKey = datKey
    var dats = []
    dats.push({
      datKey: datKey,
      userKey: user.key
    })
    # Add other cabal user dats to seed etc....
    cabalFiles.seedAll(dats)
  }
})


About

Plugin for cabal clients for message file attachments shared via dat

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published