Skip to content

Support uploading clean JSON without base64 metadata wrapping #89

Description

@crtahlin

Problem

client.upload() always wraps content in a metadata structure:

{
  "data": "<base64 of content>",
  "content_hash": "<sha256 of content>",
  "stamp_id": "..."
}

This is the SWIP-defined wrapper, but some use cases need to store clean JSON directly — e.g. dataprovenance-app stores a file-proof record (just a hash + metadata) and wants:

  • The JSON readable on Swarm without base64 decoding
  • The data field to contain the structured record directly (not base64)
  • Compatibility with gateway notary signing (which hashes the data field)

Current workaround

dataprovenance-app bypasses client.upload() entirely and POSTs directly to the gateway via fetch, using only client.acquireStamp() from the SDK.

Proposed solution

Add a raw or passthrough mode to upload() that skips the base64/metadata wrapping:

await client.upload(proofJson, { raw: true, sign: 'notary' });
// Uploads the JSON as-is, no wrapping
// Gateway can still sign it (requires data field)

Or a dedicated method:

await client.uploadDocument(proofRecord, { sign: 'notary' });
// Wraps in { data: proofRecord } if not already wrapped
// No base64 encoding

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions