This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form #registerForm="ngForm"> | |
<div class="form-group"> | |
<label for="username">Username</label> | |
<input [(ngModel)]="formData.username" | |
#username="ngModel" | |
name="username" | |
type="text" | |
class="form-control" | |
id="username" | |
required> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const multer = require('multer'); | |
const multerS3 = require('multer-s3'); | |
const aws = require('aws-sdk'); | |
aws.config.update({ | |
secretAccessKey: "ab7786ad6", // Not working key, Your SECRET ACCESS KEY from AWS should go here, never share it!!! | |
accessKeyId: "ab7786ad6", // Not working key, Your ACCESS KEY ID from AWS should go here, never share it!!! | |
region: 'us-east-1' // region of your bucket | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const upload = multer({ | |
storage: multerS3({ | |
s3: s3, | |
bucket: 'medium-test', | |
acl: 'public-read', | |
metadata: function (req, file, cb) { | |
cb(null, {fieldName: file.fieldname}); | |
}, | |
key: function (req, file, cb) { | |
cb(null, Date.now().toString()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const router = express.Router(); | |
const upload = require('../services/multer'); | |
const singleUpload = upload.single('image') | |
router.post('/image-upload', function(req, res) { | |
singleUpload(req, res, function(err, some) { | |
if (err) { | |
return res.status(422).send({errors: [{title: 'Image Upload Error', detail: err.message}] }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | |
"project": { | |
"name": "bwm-ng" | |
}, | |
"apps": [ | |
{ | |
"root": "src", | |
"outDir": "dist", | |
"assets": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "angular-starter", | |
"version": "0.0.0", | |
"license": "MIT", | |
"scripts": { | |
"ng": "ng", | |
"start": "ng serve --proxy-config proxy.conf.json", | |
"build": "ng build --prod", | |
"test": "ng test", | |
"lint": "ng lint", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label class="image-upload-container btn btn-bwm"> | |
<span>Select Image</span> | |
<input #imageInput | |
type="file" | |
accept="image/*" | |
(change)="processFile(imageInput)"> | |
</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label class="image-upload-container btn btn-bwm"> | |
<span>Select Image</span> | |
<input #imageInput | |
type="file" | |
accept="image/*" | |
(change)="processFile(imageInput)"> | |
</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImageSnippet { | |
pending: boolean = false; | |
status: string = 'init'; | |
constructor(public src: string, public file: File) {} | |
} | |
@Component({ | |
selector: 'bwm-image-upload', | |
templateUrl: 'image-upload.component.html', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImageSnippet { | |
constructor(public src: string, public file: File) {} | |
} | |
@Component({ | |
selector: 'bwm-image-upload', | |
templateUrl: 'image-upload.component.html', | |
styleUrls: ['image-upload.component.scss'] | |
}) | |
export class ImageUploadComponent { |
OlderNewer