> For the complete documentation index, see [llms.txt](https://textav.gitbook.io/firebase-react-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://textav.gitbook.io/firebase-react-notes/storage/saving-files-to-cloud-storage-from-memory.md).

# Saving files to cloud storage from memory

docs

{% embed url="<https://googleapis.dev/nodejs/storage/latest/File.html#save>" %}

```javascript
const bucket = admin.storage().bucket(testEnv.storageBucket);
const file = bucket.file(mockObject.name);
const contents = JSON.stringify(mockObject, null, 2);

file.save(contents, function(err) {
  if (!err) {
    // file written
  }
});
```

{% embed url="<https://github.com/googleapis/google-cloud-node/issues/2334#issuecomment-466032478>" %}
