Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
b75213e3
"packages/rocketchat-lib/server/functions/sendMessage.coffee" did not exist on "de94829ade2b44c277c78b6cee926ddc8a6a1618"
Commit
b75213e3
authored
9 years ago
by
Rodrigo Nascimento
Browse files
Options
Downloads
Patches
Plain Diff
Init implementation of jalik ufs for upload
parent
45a40052
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.meteor/packages
+2
-0
2 additions, 0 deletions
.meteor/packages
.meteor/versions
+2
-0
2 additions, 0 deletions
.meteor/versions
client/lib/fileUpload.coffee
+75
-15
75 additions, 15 deletions
client/lib/fileUpload.coffee
lib/fileUpload.coffee
+17
-47
17 additions, 47 deletions
lib/fileUpload.coffee
with
96 additions
and
62 deletions
.meteor/packages
+
2
−
0
View file @
b75213e3
...
@@ -80,3 +80,5 @@ yasaricli:slugify
...
@@ -80,3 +80,5 @@ yasaricli:slugify
yasinuslu:blaze-meta
yasinuslu:blaze-meta
rocketchat:colors
rocketchat:colors
raix:push@2.6.13-rc.1
raix:push@2.6.13-rc.1
jalik:ufs
jalik:ufs-gridfs
This diff is collapsed.
Click to expand it.
.meteor/versions
+
2
−
0
View file @
b75213e3
...
@@ -51,6 +51,8 @@ html-tools@1.0.4
...
@@ -51,6 +51,8 @@ html-tools@1.0.4
htmljs@1.0.4
htmljs@1.0.4
http@1.1.0
http@1.1.0
id-map@1.0.3
id-map@1.0.3
jalik:ufs@0.2.5
jalik:ufs-gridfs@0.1.0
jparker:crypto-core@0.1.0
jparker:crypto-core@0.1.0
jparker:crypto-md5@0.1.1
jparker:crypto-md5@0.1.1
jparker:gravatar@0.3.1
jparker:gravatar@0.3.1
...
...
This diff is collapsed.
Click to expand it.
client/lib/fileUpload.coffee
+
75
−
15
View file @
b75213e3
readAsDataURL
=
(
file
,
callback
)
->
reader
=
new
FileReader
()
reader
.
onload
=
(
ev
)
->
callback
ev
.
target
.
result
,
file
reader
.
readAsDataURL
file
readAsArrayBuffer
=
(
file
,
callback
)
->
reader
=
new
FileReader
()
reader
.
onload
=
(
ev
)
->
callback
ev
.
target
.
result
,
file
reader
.
readAsArrayBuffer
file
@
fileUpload
=
(
files
)
->
@
fileUpload
=
(
files
)
->
files
=
[].
concat
files
files
=
[].
concat
files
...
@@ -7,10 +22,7 @@
...
@@ -7,10 +22,7 @@
swal
.
close
()
swal
.
close
()
return
return
reader
=
new
FileReader
()
readAsDataURL
file
.
file
,
(
fileContent
)
->
reader
.
onload
=
(
event
)
->
fileContent
=
event
.
target
.
result
text
=
''
text
=
''
if
file
.
type
is
'audio'
if
file
.
type
is
'audio'
...
@@ -44,16 +56,64 @@
...
@@ -44,16 +56,64 @@
if
isConfirm
isnt
true
if
isConfirm
isnt
true
return
return
newFile
=
new
(
FS
.
File
)(
file
.
file
)
readAsArrayBuffer
file
.
file
,
(
data
)
->
if
file
.
name
?
# // Prepare the file to insert in database, note that we don't provide an URL,
newFile
.
name
(
file
.
name
)
# // it will be set automatically by the uploader when file transfer is complete.
newFile
.
rid
=
Session
.
get
(
'openedRoom'
)
record
=
newFile
.
recId
=
Random
.
id
()
name
:
file
.
name
or
file
.
file
.
name
newFile
.
userId
=
Meteor
.
userId
()
size
:
file
.
file
.
size
Files
.
insert
newFile
,
(
error
,
fileObj
)
->
type
:
file
.
file
.
type
unless
error
toastr
.
success
'Upload succeeded!'
# // Create a new Uploader for this file
upload
=
new
UploadFS
.
Uploader
reader
.
readAsDataURL
(
file
.
file
)
# // This is where the uploader will save the file
store
:
Meteor
.
fileStore
# // The file data
data
:
data
# // The document to save in the collection
file
:
record
# // The error callback
onError
:
(
err
)
->
console
.
error
(
err
)
# // The complete callback
onComplete
:
(
file
)
->
console
.
log
(
'transfer complete'
,
arguments
)
toastr
.
success
'Upload succeeded!'
Meteor
.
call
'sendMessage'
,
_id
:
Random
.
id
()
rid
:
Session
.
get
(
'openedRoom'
)
msg
:
"""
File Uploaded: *
#{
file
.
name
}
*
#{
file
.
url
}
"""
file
:
_id
:
file
.
_id
# // Reactive method to get upload progress
Tracker
.
autorun
->
console
.
log
((
upload
.
getProgress
()
*
100
)
+
'% completed'
)
# // Reactive method to get upload status
Tracker
.
autorun
->
console
.
log
(
'transfer '
+
(
upload
.
isUploading
()
?
'started'
:
'stopped'
))
# // Starts the upload
upload
.
start
();
# // Stops the upload
# upload.stop();
# // Abort the upload
# upload.abort();
# newFile = new (FS.File)(file.file)
# if file.name?
# newFile.name(file.name)
# newFile.rid = Session.get('openedRoom')
# newFile.recId = Random.id()
# newFile.userId = Meteor.userId()
# Files.insert newFile, (error, fileObj) ->
# unless error
# toastr.success 'Upload succeeded!'
consume
()
consume
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/fileUpload.coffee
+
17
−
47
View file @
b75213e3
if
FS
?
if
UploadFS
?
fileCollection
=
new
Mongo
.
Collection
'files'
@
fileStore
=
new
FS
.
Store
.
GridFS
'files'
fileCollection
.
allow
insert
:
(
userId
,
doc
)
->
return
userId
fileStore
.
on
'stored'
,
Meteor
.
bindEnvironment
(
storeName
,
fileObj
)
->
update
:
(
userId
,
doc
)
->
Meteor
.
runAsUser
fileObj
.
userId
,
->
return
userId
is
doc
.
userId
if
not
ChatMessage
.
findOne
(
fileObj
.
recId
)
?
Meteor
.
call
'sendMessage'
,
_id
:
fileObj
.
recId
rid
:
fileObj
.
rid
msg
:
"""
File Uploaded: *
#{
fileObj
.
original
.
name
}
*
#{
Meteor
.
absoluteUrl
()
}
cfs/files/Files/
#{
fileObj
.
_id
}
"""
file
:
_id
:
fileObj
.
_id
,
{
upsert
:
true
}
@
Files
=
new
FS
.
Collection
'Files'
,
remove
:
(
userId
,
doc
)
->
stores
:
[
fileStore
],
return
userId
is
doc
.
userId
filter
:
maxSize
:
2097152
,
allow
:
contentTypes
:
[
'image/*'
,
'audio/*'
]
onInvalid
:
(
message
)
->
if
Meteor
.
isClient
toastr
.
error
message
else
console
.
log
message
return
# Allow rules
Meteor
.
fileStore
=
new
UploadFS
.
store
.
GridFS
Files
.
allow
collection
:
fileCollection
insert
:
->
name
:
'files'
true
filter
:
new
UploadFS
.
Filter
update
:
->
maxSize
:
2097152
false
contentTypes
:
[
'image/*'
,
'audio/*'
]
download
:
->
onFinishUpload
:
->
true
console
.
log
arguments
remove
:
->
false
Files
.
deny
insert
:
->
false
update
:
->
true
remove
:
->
true
download
:
->
false
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment