· 7 years ago · Jul 10, 2018, 08:54 PM
1'use strict';
2 var FroalaEditor = require('../../node_modules/wysiwyg-editor-node-
3 sdk/lib/froalaEditor.js');
4 module.exports = function(server) {
5 var router = server.loopback.Router();
6 router.get('/api/get_signature', function(req, res) {
7 var configs = {
8 bucket: 'bucket',
9 region: 's3',
10
11 // The folder where to upload the images.
12 keyStart: 'email',
13
14 // File access.
15 acl: 'public-read',
16
17 // AWS keys.
18 accessKey: 'xxxxxxx',
19 secretKey: 'xxxxxxxxxx'
20 }
21
22 var s3Hash = FroalaEditor.S3.getHash(configs);
23
24 res.send(s3Hash);
25});
26server.use(router);
27}
28
29//initialize froala after getting the signature
30 public initialize(initControls) {
31 this.froala = initControls;
32 this._RestService.getEditorSignature().subscribe(
33 d => {
34 this.editorOptions['imageUploadToS3'] = d;
35 this.froala.initialize();
36 });
37 }
38
39<CORSConfiguration>
40 <CORSRule>
41 <AllowedOrigin>http://localhost:4200</AllowedOrigin>
42 <AllowedMethod>GET</AllowedMethod>
43 <AllowedMethod>POST</AllowedMethod>
44 <AllowedMethod>PUT</AllowedMethod>
45 <MaxAgeSeconds>3000</MaxAgeSeconds>
46 <AllowedHeader>Authoriz</AllowedHeader>
47 </CORSRule>
48 </CORSConfiguration>