steadyequipment / node-firestore-backup

Google Firebase Firestore backup tool
190 stars 51 forks source link

Accept any function #39

Open KRVJKvothe opened 6 years ago

KRVJKvothe commented 6 years ago

With the fileWrite, you can send any function in the options. The function must have the fields path and filecontents. That's to save the file in anywhere you want like the cloud. For example: function saveFileS3 (path, content) { const params = { Bucket: s3Bucket, Key: (new Date()).toISOString() + (!path.startsWith('/') && '/' || '0') + path, ContentType: 'application/json', Body: content }

s3.putObject( params, (err, data) => { if (err) { console.log(err) } else { console.log('Guardado: ' + path) } }) }

To save in an AWS S3 Bucket. so you send the function in the fileWrite in options, like:

firestore({ accountCredentials: { project_id: CONFIG.GOOGLE_PROJECT_ID, private_key: CONFIG.GOOGLE_PRIVATE_KEY, client_email: CONFIG.GOOGLE_CLIENT_EMAIL }, backupPath: '', fileWrite: saveFileS3 }).then(......)

Thank's you for the firestore-backup.

yoiang commented 6 years ago

@KRVJKvothe thanks so much for the PR! The idea is great, something that should have been in a long time ago. I've added a few review requests but otherwise it looks great!