How to use the blockstack.putFile function in blockstack

To help you get started, we’ve selected a few blockstack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Graphite-Docs / graphite / web / src / components / documents / Document.js View on Github external
saveNewFile() {
    // this.setState({ loading: "show" });
    // this.setState({ save: "hide"});
    blockstack.putFile("documents.json", JSON.stringify(this.state), true)
      .then(() => {
        console.log(JSON.stringify(this.state));
        window.location.href = '/';
      })
      .catch(e => {
        console.log("e");
        console.log(e);
        alert(e.message);
      });
  }
  handleCancel() {
github Graphite-Docs / graphite / web / src / components / helpers / singleVaultFile.js View on Github external
console.log(userShort + this.props.match.params.id + '.json')
        // console.log("Step Four: File Shared: " + getGlobal().shareFile);
        setGlobal({ shareModal: "hide", loading: "hide", show: "" });
        window.Materialize.toast('File shared with ' + getGlobal().receiverID, 4000);
      })
      .catch(e => {
        console.log("e");
        console.log(e);
      });
    const publicKey = getGlobal().pubKey;
    const data = getGlobal().shareFileIndex;
    const dataTwo = getGlobal().shareFile;
    const encryptedData = JSON.stringify(encryptECIES(publicKey, JSON.stringify(data)));
    const encryptedDataTwo = JSON.stringify(encryptECIES(publicKey, JSON.stringify(dataTwo)));
    const directory = '/shared/' + file;
    putFile(directory, encryptedData, {encrypt: false})
      .then(() => {

        console.log("Shared encrypted fileIndex" + directory);
      })
      .catch(e => {
        console.log(e);
      });
    putFile('/shared/' + userShort + this.props.match.params.id + '.json', encryptedDataTwo, {encrypt: false})
      .then(() => {
        console.log("Shared encrypted file");
        console.log(dataTwo);
        handleaddItem();
      })
      .catch(e => {
        console.log(e);
      });
github Graphite-Docs / graphite / src / components / helpers / singleRTC.js View on Github external
export function saveNewSingleSharedDoc() {
  const file = this.state.tempDocId;
  const fullFile = '/documents/' + file + '.json'
  putFile(fullFile, JSON.stringify(this.state.singleDoc), {encrypt:true})
    .then(() => {
      console.log("Saved!");
      if(this.state.rtc !== true) {
        window.location.replace("/documents");
      }
    })
    .catch(e => {
      console.log("e");
      console.log(e);
    });
  }
github Graphite-Docs / graphite / src / components / graphite / Yjs.js View on Github external
saveFile() {
    console.log("Saving logged in user's file")
    this.setState({count: 0, updatedAccountName: "" });
    putFile('automergeTest.json', JSON.stringify(this.state.file), {encrypt: true})
      .then(() => {
        console.log("file saved");
        this.setState({
          integrationsModal: "hide",
          accountNameModal: "hide",
          accountPlanModal: "hide",
          updateTeammateModal: "hide",
          teammateModal: "hide"
        });
        //Since this method will be reused for all saves made by the logged in user, it's helpful to always save to the other team members, so we start by loading their public keys
        this.saveToEveryone();
      })
      .catch(error => {
        console.log(error);
      })
  }
github jehunter5811 / graphite-blockstack / src / components / messages / Conversations.js View on Github external
saveNewFile() {
    const fileName = this.state.conversationUser.slice(0, -3) + '.json';
    putFile(fileName, JSON.stringify(this.state), {encrypt: true})
      .then(() => {
        this.setState({deleteShow: "hide"});
        this.saveShared();
      })
      .catch(e => {
        console.log(e);
      });
  }
github Graphite-Docs / graphite / web / src / components / sheets / SingleSheet.js View on Github external
autoSave() {

  const file = this.props.match.params.id;
  const fullFile = '/sheets/' + file + '.json';
  if(this.state.singleSheet.form === true) {
    putFile(fullFile, JSON.stringify(this.state.singleSheet), {encrypt: false})
      .then(() => {
        console.log("Autosaved");
        this.saveCollection();
      })
      .catch(e => {
        console.log("e");
        console.log(e);
      });
  } else {
    putFile(fullFile, JSON.stringify(this.state.singleSheet), {encrypt: true})
      .then(() => {
        console.log("Autosaved");
        this.saveCollection();
      })
      .catch(e => {
        console.log("e");
        console.log(e);
      });
  }

}
github Graphite-Docs / graphite / web / src / components / helpers / accountPlan.js View on Github external
.catch(error => {
      console.log(error);
    })

  putFile('inviter.json', JSON.stringify({}), {encrypt: true})
    .catch(error => {
      console.log(error);
    });


  putFile('inviteStatus.json', JSON.stringify({}), {encrypt: true})
    .catch(error => {
      console.log(error);
    })

  putFile("accountdetailsMain.json", JSON.stringify({}), {encrypt: false})
    .catch(error => {
      console.log(error)
    })
}
github Graphite-Docs / graphite / web / src / components / helpers / singleVaultFile.js View on Github external
export function saveToDocs() {
    putFile("documentscollection.json", JSON.stringify(getGlobal().value), { encrypt: true })
      .then(() => {
        console.log("Saved!");
        saveToDocsTwo();
      })
      .catch(e => {
        console.log("e");
        console.log(e);
      });
  }
export function saveToDocsTwo() {
github Graphite-Docs / graphite / web / src / components / helpers / documents.js View on Github external
export function saveSingleFile(doc) {
  const file = doc.id;
  const fullFile = '/documents/' + file + '.json'
  putFile(fullFile, JSON.stringify(getGlobal().singleDoc), {encrypt:true})
    .then(() => {
      console.log("Saved!");
      saveCollection();
    })
    .catch(e => {
      console.log("e");
      console.log(e);
    });
}
github blockstack / cli-blockstack / src / cli.ts View on Github external
.then((_userData : UserData) => {      
      return blockstack.putFile(gaiaPath, data, { encrypt: encrypt, sign: sign });
    })
    .then((url : string) => {