Browse Source

Merge pull request #224 from moxiegirl/fix-storage

Adding in right way to use UserSession
feat/clarity-updates
Moxiegirl 6 years ago
committed by GitHub
parent
commit
48c247f262
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      _develop/storage.md

20
_develop/storage.md

@ -20,10 +20,11 @@ The Blockstack Platform stores application data in the Gaia Storage System. Tran
You use the <a href="https://blockstack.github.io/blockstack.js/classes/usersession.html#putfile" target="_blank">UserSession.putFile</a> You use the <a href="https://blockstack.github.io/blockstack.js/classes/usersession.html#putfile" target="_blank">UserSession.putFile</a>
```JavaScript ```JavaScript
var userSession = new UserSession()
let options = { let options = {
encrypt: false encrypt: false
} }
blockstack.UserSession.putFile("/hello.txt", "hello world!", options) userSession.putFile("/hello.txt", "hello world!", options)
.then(() => { .then(() => {
// /hello.txt exists now, and has the contents "hello world!". // /hello.txt exists now, and has the contents "hello world!".
}) })
@ -34,11 +35,13 @@ let options = {
You use the <a href="https://blockstack.github.io/blockstack.js/classes/usersession.html#putfile" target="_blank"></a> You use the <a href="https://blockstack.github.io/blockstack.js/classes/usersession.html#putfile" target="_blank"></a>
```JavaScript ```JavaScript
var userSession = new UserSession()
let options = { let options = {
encrypt: true encrypt: true
} }
blockstack.UserSession.putFile("/message.txt", "Secret hello!", options) userSession.putFile("/message.txt", "Secret hello!", options)
.then(() => { .then(() => {
// message.txt exists now, and has the contents "hello world!". // message.txt exists now, and has the contents "hello world!".
}) })
@ -49,11 +52,13 @@ You use the <a href="https://blockstack.github.io/blockstack.js/classes/usersess
You use the <a href="https://blockstack.github.io/blockstack.js/classes/usersession.html#getfile" target="_blank"></a> You use the <a href="https://blockstack.github.io/blockstack.js/classes/usersession.html#getfile" target="_blank"></a>
```JavaScript ```JavaScript
var userSession = new UserSession()
let options = { let options = {
decrypt: false decrypt: false
} }
blockstack.UserSession.getFile("/hello.txt", options) userSession.getFile("/hello.txt", options)
.then((fileContents) => { .then((fileContents) => {
// get the contents of the file /hello.txt // get the contents of the file /hello.txt
assert(fileContents === "hello world!") assert(fileContents === "hello world!")
@ -65,11 +70,13 @@ You use the <a href="https://blockstack.github.io/blockstack.js/classes/usersess
You use the <a href="" target="_blank"></a> You use the <a href="" target="_blank"></a>
```JavaScript ```JavaScript
var userSession = new UserSession()
let options = { let options = {
decrypt: true decrypt: true
} }
blockstack.UserSession.getFile("/message.txt", options) userSession.getFile("/message.txt", options)
.then((fileContents) => { .then((fileContents) => {
// get & decrypt the contents of the file /message.txt // get & decrypt the contents of the file /message.txt
assert(fileContents === "Secret hello!") assert(fileContents === "Secret hello!")
@ -100,7 +107,10 @@ You use the <a href="https://blockstack.github.io/blockstack.js/classes/usersess
```JavaScript ```JavaScript
blockstack.deleteFile("/hello.txt")
var userSession = new UserSession()
userSession.deleteFile("/hello.txt")
.then(() => { .then(() => {
// /hello.txt is now removed. // /hello.txt is now removed.
}) })

Loading…
Cancel
Save