Offline Sign

API Endpoint

http://127.0.0.1:5001/api/v1/storage/upload/sign?

Input Parameters

ArgumentRequired?TypeDescriptionRequired?
session-idYstringID for the storage upload session.Y
peer-idNstringClient that requires the offline signsN
nonce-timestampYint64Timestamp used for nonce. Must be within 1 hour of server time.N
upload-session-signatureYstringPrivate key-signed string of “::” for this delegated request.N
session-statusYstringThe “status” API session status that is received right before calling this API.N
signedNstringThe signed JSON string according to the unsigned response struct. This struct type is based on the session-status.N

Usage

async sign(event, data) {
  let input  = {
    SessionId: this.state.added_session_id,
    SessionStatus: this.state.added_session_status,
    Hash: this.state.added_file_hash,
    Unsigned: data,
    TimeNonce: this.time,
    PrivKey: config.PrivKey,
    PeerID: config.PeerID
  }
  const signResponse = this.btfs.sign(input, {})
  try {
    for await (const response of signResponse) {
    }
  } catch (err) {
    console.error(err)
  }
}
// Usage:

sessionId, err := s.StorageUploadOffSign(hash, uts)


// Go Wrapper:

func (s *Shell) StorageUploadOffSign(hash string, uts string, options ...StorageUploadOpts) (string, error) {
	var out storageUploadResponse
	offlinePeerSessionSignature, err := NewSessionSignature(hash, utils.GetPeerId(), uts, false)
	if err != nil {
		return "", err
	}
	rb := s.Request("storage/upload/offline", hash, utils.GetPeerId(), uts, offlinePeerSessionSignature)
	for _, option := range options {
		_ = option(rb)
	}
	return out.ID, rb.Exec(context.Background(), &out)
}
curl -X POST "http://localhost:5001/api/v1/storage/upload?arg=QmdBX8seLx4TGHwr8Tu9L2QSByaJ9bbFUpxFvKAYyxCf7b&price=750000&storage-length=35"

Response

{
}