blob.go raw

   1  //go:build js && wasm
   2  
   3  package wasmdb
   4  
   5  import (
   6  	"errors"
   7  
   8  	"next.orly.dev/pkg/database"
   9  )
  10  
  11  // Blob storage methods - WasmDB does not support blob storage
  12  // These are stub implementations that return errors.
  13  // Blob storage is not supported in the browser environment due to
  14  // IndexedDB size limitations and the complexity of binary data handling.
  15  
  16  var errBlobNotSupported = errors.New("blob storage not supported in WasmDB backend")
  17  
  18  // SaveBlob stores a blob with its metadata (not supported in WasmDB)
  19  func (w *W) SaveBlob(sha256Hash []byte, data []byte, pubkey []byte, mimeType string, extension string) error {
  20  	return errBlobNotSupported
  21  }
  22  
  23  // SaveBlobMetadata stores only metadata for a blob (not supported in WasmDB)
  24  func (w *W) SaveBlobMetadata(sha256Hash []byte, size int64, pubkey []byte, mimeType string, extension string) error {
  25  	return errBlobNotSupported
  26  }
  27  
  28  // GetBlob retrieves blob data by SHA256 hash (not supported in WasmDB)
  29  func (w *W) GetBlob(sha256Hash []byte) (data []byte, metadata *database.BlobMetadata, err error) {
  30  	return nil, nil, errBlobNotSupported
  31  }
  32  
  33  // HasBlob checks if a blob exists (not supported in WasmDB)
  34  func (w *W) HasBlob(sha256Hash []byte) (exists bool, err error) {
  35  	return false, errBlobNotSupported
  36  }
  37  
  38  // DeleteBlob deletes a blob and its metadata (not supported in WasmDB)
  39  func (w *W) DeleteBlob(sha256Hash []byte, pubkey []byte) error {
  40  	return errBlobNotSupported
  41  }
  42  
  43  // ListBlobs lists all blobs for a given pubkey (not supported in WasmDB)
  44  func (w *W) ListBlobs(pubkey []byte, since, until int64) ([]*database.BlobDescriptor, error) {
  45  	return nil, errBlobNotSupported
  46  }
  47  
  48  // GetBlobMetadata retrieves only metadata for a blob (not supported in WasmDB)
  49  func (w *W) GetBlobMetadata(sha256Hash []byte) (*database.BlobMetadata, error) {
  50  	return nil, errBlobNotSupported
  51  }
  52  
  53  // GetTotalBlobStorageUsed calculates total storage used by a pubkey in MB (not supported in WasmDB)
  54  func (w *W) GetTotalBlobStorageUsed(pubkey []byte) (totalMB int64, err error) {
  55  	return 0, errBlobNotSupported
  56  }
  57  
  58  // SaveBlobReport stores a report for a blob (not supported in WasmDB)
  59  func (w *W) SaveBlobReport(sha256Hash []byte, reportData []byte) error {
  60  	return errBlobNotSupported
  61  }
  62  
  63  // ListAllBlobUserStats returns storage statistics for all users (not supported in WasmDB)
  64  func (w *W) ListAllBlobUserStats() ([]*database.UserBlobStats, error) {
  65  	return nil, errBlobNotSupported
  66  }
  67