-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53ede40
commit 416c35b
Showing
7 changed files
with
104 additions
and
79 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Meteor.startup -> | ||
Template.uploadForm.onCreated -> | ||
@error = new ReactiveVar false | ||
@uploadInstance = new ReactiveVar false | ||
|
||
Template.uploadForm.helpers | ||
error: -> Template.instance().error.get() | ||
uploadInstance:-> Template.instance().uploadInstance.get() | ||
|
||
Template.uploadForm.events | ||
'click #pause': -> @pause() | ||
'click #abort': -> @abort() | ||
'click #continue': -> @continue() | ||
'change input[name="userfile"]': (e, template) -> template.$('form#uploadFile').submit() | ||
'submit form#uploadFile': (e, template) -> | ||
e.preventDefault() | ||
template.error.set false | ||
files = e.currentTarget.userfile.files | ||
|
||
unless files.length | ||
template.error.set "Please select a file to upload" | ||
return false | ||
|
||
done = false | ||
created_at = +new Date | ||
template.uploadInstance.set Collections.files.insert | ||
file: files[0] | ||
meta: {expireAt: new Date(created_at + _app.storeTTL), created_at, downloads: 0} | ||
onUploaded: (error, fileObj) -> | ||
done = true | ||
unless error | ||
Router.go 'file', _id: fileObj._id | ||
else | ||
template.error.set error.reason | ||
template.uploadInstance.set false | ||
onAbort: -> | ||
done = true | ||
template.uploadInstance.set false | ||
onBeforeUpload: -> if @size <= 100000 * 10 * 128 then true else "Max. file size is 128MB you've tried to upload #{filesize(@size)}" | ||
streams: 8 | ||
false |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
template(name="uploadForm") | ||
form.navbar-form.center#uploadFile | ||
if error | ||
.alert.alert-danger {{error}} | ||
|
||
unless uploadInstance | ||
.input-group | ||
input.form-control.btn.btn-default(title="Select File" type="file" name="userfile" required) | ||
span.input-group-btn | ||
button.btn.btn-primary(type="submit" title="Upload File") | ||
i.fa.fa-lg.fa-cloud-upload | ||
| Upload | ||
small.text-center.help-block Any file-type. With size less or equal to 128MB | ||
|
||
if uploadInstance | ||
+with uploadInstance | ||
table: tbody | ||
tr | ||
td | ||
.btn-group | ||
if onPause.get | ||
button#continue.btn.btn-default.btn-sm(type="button" title="Resume upload") | ||
i.fa.fa-fw.fa-play | ||
else | ||
button#pause.btn.btn-default.btn-sm(type="button" title="Pause upload") | ||
i.fa.fa-fw.fa-pause | ||
button#abort.btn.btn-default.btn-sm(type="button" title="Abort upload") | ||
i.fa.fa-fw.fa-stop | ||
td: .progress.center: .progress-bar.progress-bar-striped.active(aria-valuemin="0" aria-valuemax="100" style="width: {{progress.get}}%") | ||
tr: td.center(colspan="2"): small.text-center.help-block(style="margin-bottom:0px") You are free to browse the site while upload in progress |
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