Skip to content

Instantly share code, notes, and snippets.

@janniks
Last active April 27, 2022 14:19
Show Gist options
  • Save janniks/054a8687e57d6eb87dd83094b71fa0fd to your computer and use it in GitHub Desktop.
Save janniks/054a8687e57d6eb87dd83094b71fa0fd to your computer and use it in GitHub Desktop.
putFile — Stacks Storage
import { AppConfig, UserSession } from "@stacks/connect";
import { Storage } from "@stacks/storage";
const appConfig = new AppConfig(["store_write", "publish_data"]);
const userSession = new UserSession({ appConfig });
const storage = new Storage({ userSession });
const fileName = "car.json";
const fileData = {
color: "blue",
electric: true,
purchaseDate: "2019-04-03",
};
const options = {
encrypt: true,
};
const fileUrl = await storage.putFile(fileName, JSON.stringify(fileData), options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment