aaden-cli 1.1.115 → 1.1.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/aws.js +43 -0
  2. package/dist/index.js +53895 -14615
  3. package/index.js +25 -16
  4. package/package.json +4 -1
package/aws.js ADDED
@@ -0,0 +1,43 @@
1
+ const AWS = require('aws-sdk')
2
+ const fs = require('fs')
3
+ const loadIniFile = require('read-ini-file')
4
+
5
+ const id = 'AKIA4TTJEQRYQ7CBPK5W'
6
+ const secret = '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'
7
+ const bucketName = 'aaden-backup-bucket'
8
+
9
+ const s3 = new AWS.S3({
10
+ accessKeyId: id,
11
+ secretAccessKey: secret
12
+ })
13
+
14
+ function getMyDeviceId () {
15
+ const loadIniFile = require('read-ini-file')
16
+ try {
17
+ return loadIniFile.sync('/var/www/html/Resource/config/config.ini').Device.DeviceId
18
+ } catch (e) {
19
+ return -1
20
+ }
21
+
22
+ }
23
+
24
+ const uploadFile = (fileName) => {
25
+ const fileContent = fs.readFileSync(fileName)
26
+
27
+ const params = {
28
+ Bucket: bucketName,
29
+ Key: getMyDeviceId() + '/backups/' + 'backup.sql',
30
+ Body: fileContent
31
+ }
32
+
33
+ s3.upload(params, function (err, data) {
34
+ if (err) {
35
+ throw err
36
+ }
37
+ console.log(`File uploaded successfully. ${data.Location}`)
38
+ })
39
+ }
40
+
41
+ module.exports = {
42
+ uploadFile
43
+ }