npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@galacfetch/remote-ipfs-file-manager

v0.1.4

Published

hiii

Downloads

3

Readme

remoteIpfsFileManager Library Documentation

Overview

remoteIpfsFileManager, a component of the @galacfetch/hooks collection, enhances the handling of remote file operations in React applications via the InterPlanetary File System (IPFS). It focuses on efficient file uploading, downloading, metadata management, and interactivity with remote IPFS nodes, while utilizing WebSocket connections for data transfer.

Key Features

  • Enhanced File Management: Facilitates the upload and download of files to and from remote IPFS nodes.
  • Metadata Management and Extended Capabilities: Offers comprehensive handling of file properties including file statistics and metadata updates.
  • WebSocket Integration: Works in conjunction with secureConnectManager for reliable WebSocket communication with remote servers.

Initialization

To set up the manager:

import React, { useEffect, useState } from 'react'
import { indexDbStore } from '@galacfetch/indexdb'
import { secureConnectManager } from '@galacfetch/secure-connect-manager'
import { remoteIpfsFileManager } from '@galacfetch/remote-ipfs-file-manager'

export const InitializeAllModules: React.FC = () => {
  const { initIndexedDb } = indexDbStore()
  const { init: initConnectManager, intervalId } = secureConnectManager()
  const { init: initRemoteIpfsFileManager } = remoteIpfsFileManager()

  const [apiKey, setApiKey] = useState('')
  const [status, setStatus] = useState({
    indexDb: 'Not initialized',
    secureConnect: 'Not initialized',
    remoteIpfsFileManager: 'Not initialized',
  })

  useEffect(() => {
    if (intervalId) {
      setStatus((prev) => ({ ...prev, secureConnect: 'Initialized' }))
    } else {
      setStatus((prev) => ({ ...prev, secureConnect: 'Not initialized' }))
    }
  }, [intervalId])

  const handleInitialize = async () => {
    try {
      // Initialize indexDbStore
      await initIndexedDb('myDatabase')
      setStatus((prev) => ({ ...prev, indexDb: 'Initialized' }))

      // Initialize secureConnectManager with the API key
      initConnectManager({
        api: apiKey,
        discoveryInterval: 60000, // adjust as needed
      })

      // Initialize remoteIpfsFileManager (assuming no additional config needed)
      initRemoteIpfsFileManager()
      setStatus((prev) => ({ ...prev, remoteIpfsFileManager: 'Initialized' }))
    } catch (error) {
      console.error('Error initializing modules:', error)
    }
  }

  return (
    <div>
      <h3>Initialize All Required Modules</h3>
      <input
        type="text"
        value={apiKey}
        onChange={(e) => setApiKey(e.target.value)}
        placeholder="Enter API Key for SecureConnectManager"
      />
      <button onClick={handleInitialize}>Initialize</button>
      <div>
        <p>IndexDB Status: {status.indexDb}</p>
        <p>SecureConnectManager Status: {status.secureConnect}</p>
        <p>RemoteIpfsFileManager Status: {status.remoteIpfsFileManager}</p>
      </div>
    </div>
  )
}

File Operations

Uploading Files

const file = /* File object */;
const fileProps = {
  name: 'example.txt',
  description: 'Description of the file',
  extraProperties: { /* Custom properties */ },
  isPublic: true,
};

remoteIpfsFileManager().remoteUploadFile(file, fileProps)
  .then(data => console.log('File uploaded:', data))
  .catch(error => console.error('Error uploading file:', error));

Downloading Files

const cid = 'uniqueCID' // File CID

remoteIpfsFileManager()
  .remoteGetFile(cid)
  .then((url) => console.log('File download URL:', url))
  .catch((error) => console.error('Error downloading file:', error))

Managing File Metadata

const updatedProps = {
  name: 'updatedName.txt',
  description: 'New file description',
  // Additional properties
}

// Update metadata
remoteIpfsFileManager()
  .remoteUpdateFile('uniqueCID', updatedProps)
  .then((data) => console.log('File metadata updated:', data))
  .catch((error) => console.error('Error updating file metadata:', error))

// Retrieve extra properties
remoteIpfsFileManager()
  .remotegetFileExtraProps('uniqueCID')
  .then((data) => console.log('Extra properties:', data))
  .catch((error) => console.error('Error retrieving extra properties:', error))

New Features

File Statistics

Provides methods for retrieving statistical data of files, enhancing monitoring and analysis capabilities.

// Fetch file statistics
remoteIpfsFileManager()
  .remoteGetFileStats('uniqueCID', startDate, endDate)
  .then((stats) => console.log('File statistics:', stats))
  .catch((error) => console.error('Error fetching file stats:', error))

// Fetch token usage statistics
remoteIpfsFileManager()
  .remoteGetTokenStats(startDate, endDate)
  .then((stats) => console.log('Token statistics:', stats))
  .catch((error) => console.error('Error fetching token stats:', error))

Advanced Features

WebSocket Connection Management

remoteIpfsFileManager collaborates with secureConnectManager to facilitate WebSocket connections for file transfers, ensuring robust communication with remote servers saving bandwidth and time.

File Information Retrieval

Allows querying of file information, both individually and collectively, with optional public visibility filters and query parameters for advanced search and sorting.

Compositions Explanation

Initialization of All Required Modules

A React composition to initialize remoteIpfsFileManager alongside other essential modules such as secureConnectManager and indexDbStore.

File Upload Form

Provides a user interface for selecting and uploading files through remoteIpfsFileManager, including handling file metadata.

Files List with Filters

Enables users to view a list of files, applying filters to search and retrieve files from the backend using remoteIpfsFileManager.

Contributing

Contributions to remoteIpfsFileManager are welcome. For suggestions or bug fixes, please submit a pull request or open an issue on our GitHub repository: