@cryptolize/persistence v2.0.2
Install
npm install @cryptolize/persistence --save
Usage
ES6 (Javascript Modules)
import { S3Storage } from '@cryptolize/persistence'
S3Storage.saveFile(bucket, file, filename, progress).then((filename) => console.log(filename))ES5 (CommonJS)
var CryptolizePersistence = require('@cryptolize/persistence')
var S3Storage = CryptolizePersistence.S3Storage
S3Storage.saveFile(bucket, file, filename, progress).then((filename) => console.log(filename))UMD (Browser)
CryptolizePersistence.S3Storage.saveFile(bucket, file, filename, progress).then((filename) => console.log(filename))API
S3Storage
saveText
Saves text to S3
Parameters
bucketAWS.S3textStringfilenameStringparamsObject additonal params to attach to the requestprogressStorageInterface~ProgressCallback?
Returns Promise<(AWS.Response | Error)> the response
getText
Gets text from S3
Parameters
bucketAWS.S3filenameStringparamsObject additonal params to attach to the requestprogressStorageInterface~ProgressCallback?
Returns Promise<(AWS.Response | Error)> the requested text in the Body property
saveObject
Saves object to S3
Parameters
bucketAWS.S3objectObjectfilenameStringparamsObject additonal params to attach to the requestprogressStorageInterface~ProgressCallback?
Returns Promise<(AWS.Response | Error)> the response
getObject
Gets object from S3
Parameters
bucketAWS.S3filenameStringparamsObject additonal params to attach to the requestprogressStorageInterface~ProgressCallback?
Returns Promise<(AWS.Response | Error)> the requested object in the Body property
saveFile
Saves file to S3
Parameters
bucketAWS.S3fileArrayBufferfilenameStringparamsObject additonal params to attach to the requestprogressStorageInterface~ProgressCallback?
Returns Promise<(AWS.Response | Error)> the response
getFile
Gets file from S3
Parameters
bucketAWS.S3filenameStringparamsObject additonal params to attach to the requestprogressStorageInterface~ProgressCallback?
Returns Promise<(AWS.Response | Error)> the requested file in the Body property
LocalStorage
Parameters
saveAstextfilenametype(optional, default'application/octet-stream')
saveText
Saves text
Parameters
saveAssaveAs https://github.com/eligrey/FileSaver.jstextStringfilenameStringtype(optional, default'application/octet-stream')
Returns Promise<String> file's name
saveObject
Saves object
Parameters
saveAssaveAs https://github.com/eligrey/FileSaver.jsobjectObjectfilenameStringtype
Returns Promise<String> file's name
saveFile
Saves file
Parameters
saveAssaveAs https://github.com/eligrey/FileSaver.jsfileArrayBufferfilenameStringtype
Returns Promise<String> file's name
RecordSerialization
serialize
Serialize record
Parameters
recordRecord the record without data property in the files's objects
Returns String
deserialize
Deserialize record
Parameters
recordString
Returns Record the record without data property in the files's objects
serializeURL
Serialize record to be url compatible
Parameters
recordRecord the record without data property in the files's objects
Returns String
deserializeURL
Deserialize record from url serialization
Parameters
recordString
Returns Record the record without data property in the files's objects
Record
save
Save record
Parameters
recordIdString the id under which to save the recordrecordRecord the record without data property in the files's objectsserializeRecord(RecordSerialization~serialize | RecordSerialization~serializeURL)saveTextStorageInterface~saveText
Returns Promise<(String | Error)> record id
get
Get record
Parameters
recordIdStringdeserializeRecord(RecordSerialization~deserialize | RecordSerialization~deserializeURL)getTextStorageInterface~getText
Returns Promise<(Record | Error)> the record without data property in the files's objects
extract
Extract record
Extract only the record part in order to serialize it before persistence
Parameters
recordRecord
Returns Record the record without files property in the blocks
Files
save
Save files
Parameters
filesArray<EncryptedFile>saveFileStorageInterface~saveFile
Returns Promise<(Array<AWS.Response> | Error)>
get
Get files
Parameters
Returns Promise<(Array<EncryptedFile> | Error)>
extract
Extract files
Extract only the files part in order to persist it
Parameters
recordRecord
Returns Array<EncryptedFile>
RecordAndFiles
save
Save record and files
Parameters
recordIdString the id under which to save the recordrecordArray<Record>serializeRecord(RecordSerialization~serialize | RecordSerialization~serializeURL)saveTextStorageInterface~saveTextsaveFileStorageInterface~saveFile
Returns Promise<(String | Error)> record id
saveAndSerializeRecord
Save files and serialize record
Parameters
recordArray<Record>serializeRecord(RecordSerialization~serialize | RecordSerialization~serializeURL)saveFileStorageInterface~saveFile
Returns Promise<(String | Error)> serialized record
StorageInterface
ProgressCallback
Parameters
GetFile
Parameters
Returns Promise<(ArrayBuffer | Error)> the requested file
SaveFile
Parameters
fileArrayBufferfilenameStringpathStringserviceString
Returns Promise<(String | Error)> file's name
GetObject
Parameters
Returns Promise<(Object | Error)> the requested object
SaveObject
Parameters
Returns Promise<(String | Error)> object's name
GetText
Parameters
Returns Promise<(String | Error)> the requested text
SaveText
Parameters
Returns Promise<(String | Error)> file's name
Development
- make sure node installed - install nvm if not
git clone git@bitbucket.org:witalize/cryptolize-persistence.gitcd cryptolize-persistencenpm install- lint code -
npm run lint - run tests -
npm test - build from src -
npm run build - update README -
npm run docs - publish to npm (runs automatically tests, lint and build before) -
npm publish
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago