Skip to content

Commit

Permalink
Merge pull request #320 from rockhouse/FileUploads
Browse files Browse the repository at this point in the history
File uploads
  • Loading branch information
engelgabriel committed Jul 21, 2015
2 parents 171fc72 + 821a122 commit 7318917
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ less
meteor-platform
reactive-var
service-configuration

chrismbeckett:toastr
francocatena:status
jparker:gravatar
kevohagan:sweetalert
konecty:autolinker
konecty:change-case
konecty:delayed-task
konecty:mongo-counter
konecty:multiple-instances-status
konecty:nrr
konecty:user-presence
mizzao:autocomplete
mizzao:timesync
Expand Down Expand Up @@ -56,6 +53,11 @@ tmeasday:errors
todda00:friendly-slugs
underscorestring:underscore.string
yasaricli:slugify
konecty:nrr
kevohagan:sweetalert
raix:ui-dropped-event
cfs:standard-packages
cfs:gridfs
meteorhacks:kadira
meteorhacks:flow-router
meteorhacks:flow-layout
Expand Down
17 changes: 17 additions & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,23 @@ blaze@2.1.2
blaze-tools@1.0.3
boilerplate-generator@1.0.3
callback-hook@1.0.3
cfs:access-point@0.1.49
cfs:base-package@0.0.30
cfs:collection@0.5.5
cfs:collection-filters@0.2.4
cfs:data-man@0.0.6
cfs:file@0.1.17
cfs:gridfs@0.0.33
cfs:http-methods@0.0.29
cfs:http-publish@0.0.13
cfs:power-queue@0.9.11
cfs:reactive-list@0.0.9
cfs:reactive-property@0.0.4
cfs:standard-packages@0.5.9
cfs:storage-adapter@0.2.2
cfs:tempstore@0.1.5
cfs:upload-http@0.0.20
cfs:worker@0.1.4
check@1.0.5
chrismbeckett:toastr@2.1.0
coffeescript@1.0.6
Expand Down Expand Up @@ -83,6 +99,7 @@ percolatestudio:synced-cron@1.1.0
qnub:emojione@0.0.3
raix:eventemitter@0.1.2
raix:handlebar-helpers@0.2.4
raix:ui-dropped-event@0.0.7
random@1.0.3
reactive-dict@1.1.0
reactive-var@1.0.5
Expand Down
19 changes: 19 additions & 0 deletions client/views/app/room.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,25 @@ Template.room.events
'click .stop-video': (event) ->
webrtc.stop()

'dragenter #dropzone': (e) ->
console.log 'DRAG ENTER'

'dragleave #dropzone': (e) ->
console.log 'DRAG OUT'

'dropped #dropzone': (e) ->
FS.Utility.eachFile e, (file) ->
newFile = new (FS.File)(file)
newFile.room = Session.get('openedRoom')
Files.insert newFile, (error, fileObj) ->
if error
toastr.error 'Upload failed... please try again. Error: ' + error
else
toastr.success 'Upload succeeded!'
`input = { value: 'File Uploaded: http://localhost:3000/cfs/files/Files/'+fileObj._id}`
ChatMessages.send(newFile.room, input)


Template.room.onCreated ->
console.log 'room.onCreated' if window.rocketDebug
# this.scrollOnBottom = true
Expand Down
2 changes: 2 additions & 0 deletions client/views/app/room.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<template name="room">
<div id=dropzone>
<section class="messages-container" id="{{windowId}}">
<header class="fixed-title">
<div class="burger">
Expand Down Expand Up @@ -223,4 +224,5 @@ <h3>{{username}}</h3>
{{> social}}
</footer>
</section>
</div>
</template>
39 changes: 39 additions & 0 deletions lib/fileUpload.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
if Meteor.isServer
fileStore = new (FS.Store.GridFS)('files', {})
`Files = new FS.Collection('Files', {
stores: [fileStore],
filter: { allow: { contentTypes: ['image/*'] } }
})`

if Meteor.isClient
fileStore = new (FS.Store.GridFS)('files')
`Files = new FS.Collection('Files', {
stores: [fileStore],
filter: {
maxSize: 1048576,
allow: { contentTypes: ['image/*'] },
onInvalid: function (message) {
toastr.error(message);
}
}
})`
# Allow rules
Files.allow
insert: ->
true
update: ->
false
download: ->
true
remove: ->
false

Files.deny
insert: ->
false
update: ->
true
remove: ->
true
download: ->
false

0 comments on commit 7318917

Please sign in to comment.