Official Storage Solution of AI Network Blockchain.
you can choose what type of storage to use in your code. Currently ain-storage supports local and firebase storage.
adapter
provider
: type of storage to usepath
: designated path in the storage
Local storage
const config = {
adapter: {
provider: 'local',
path: process.cwd(),
}
}
const adapterClient = adapter_interface.create(config)
Firebase storage
const config = {
adapter: {
provider: 'firebase',
path: 'trainModel/test',
},
}
const firebase_config = require('<path_to_your_firebase_config>')
config = Object.assign({}, config, firebase_config)
const adapterClient = require('./adapter_interface').create(config)
Firebase configuration (firebase docs)
apiKey
authDomain
databaseURL
projectId
storageBucket
messagingSenderId
appId
measurementId
appName
- (optional) to specify name for this app, otherwise the same as appId
parameters
file
- File or blob object to be uploadedoptions
path
- relative path for a file to be uploadedfileName
- file name to be designateddispatch
- (optional) function to dispatch events during this processdispatchType
- (optional) type defining progress of uploading a fileafterUploaded
- (optional) async function to execute when uploading is done
adapterClient.upload(file, options)
parameters
storagePath
- relative path for a file to be downloadedoptions
destPath
- local path to be downloaded
adapterClient.download(storagePath, options)
For testing with firebase, You need to set up configurations for firebase in test/private/firebase_config.js