-
Notifications
You must be signed in to change notification settings - Fork 81
/
index.html
127 lines (122 loc) · 4.96 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!doctype html>
<html ng-app="angular-s3-upload">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Angular AWS S3 Upload</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Styles -->
<link rel="stylesheet" href="components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="components/toastr/toastr.min.css">
<link rel="stylesheet" href="css/style.css">
<!-- JavaScript Libs -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="components/angular/angular.js"></script>
<script src="components/toastr/toastr.min.js"></script>
<script src="components/aws-sdk-js/dist/aws-sdk.min.js"></script>
<!-- Our JavaScript -->
<script src="js/application.js"></script>
<script src="js/controllers.js"></script>
<script src="js/directives.js"></script>
</head>
<body ng-controller="UploadController">
<div class="container-fluid">
<div class="page-header no-top-marg">
<div class="fr author">
<a target="_blank" href="http://www.cheynewallace.com">
<span>By Cheyne Wallace</span>
<img alt="By Cheyne Wallace" class="img-circle left-marg-10" height="40" src="https://secure.gravatar.com/avatar/cf0414cc7a83fabb2b0e6cb79e11e5a5.jpg?s=40" width="40">
</a>
</div>
<h1>AngularJS To S3 Upload <small>With AWS JS SDK</small></h1>
</div>
<div class="row">
<!-- AWS Details-->
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Step 1: Input Your AWS Details</h3>
</div>
<div class="panel-body">
<div class="input-group bottom-marg-10">
<span class="input-group-addon">ACCESS KEY</span>
<input ng-model="creds.access_key" type="text" class="form-control" placeholder="2992SD29299">
</div>
<div class="input-group bottom-marg-10">
<span class="input-group-addon">SECRET KEY</span>
<input ng-model="creds.secret_key" type="text" class="form-control" placeholder="AKS72628SE28">
</div>
<div class="input-group">
<span class="input-group-addon">BUCKET</span>
<input ng-model="creds.bucket" type="text" class="form-control" placeholder="my_upload_bucket">
</div>
</div>
</div>
</div>
<!-- The Upload Form -->
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">
<select class="fr" ng-model="sizeLimit">
<option value="5292880">5MB Upload Limit</option>
<option value="10585760">10MB Upload Limit</option>
<option value="15878640">15MB Upload Limit</option>
</select>
<h3 class="panel-title">Step 2: Upload The File</h3>
</div>
<div class="panel-body">
<input class="bottom-marg-15" type="file" name="file" file></input>
<!-- Progress Bar -->
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="{{ uploadProgress }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ uploadProgress }}%;">
{{ uploadProgress == 0 ? '' : uploadProgress + '%' }}
</div>
</div>
<a class="btn btn-primary btn-block btn-lg" ng-click="upload()">Upload</a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<hr/>
<h3>Features</h3>
<ul>
<li>Creates Unique Bucket Object Name</li>
<li>File Input Directive Binds Attributes To $scope.file</li>
<li>Validates File Existence</li>
<li>Validates File Size (Use Select Box To Test)</li>
<li>Validates AWS Credentials</li>
</ul>
<hr/>
<h3>IAM Policy Warning</h3>
<p>
Please make sure that if you use this code you create an appropriate IAM account policy to prevent mis-use. Example, a policy like the following would only allow PUT access to the bucket for a specific IAM user. You could also set the bucket objects to automatically expire after 24 hours which would prevent people flooding your account.
</p>
<pre class="top-marg-10">
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt126637111000",
"Effect": "Allow",
"Action": [
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::your_bucket_name"
]
}
]
}</pre>
<hr/>
<h3>Fork This Repo</h3>
<p>
Want a copy of this app? Fork it now at: <a href="https://github.com/cheynewallace/angular-s3-upload">https://github.com/cheynewallace/angular-s3-upload</a>
</p>
</div>
</div>
</div>
</body>
</html>