@@ -585,7 +585,7 @@ class FilesCollection
585
585
sp = storagePath
586
586
else if _ .isFunction storagePath
587
587
sp = storagePath .call self, " assets#{ nodePath .sep } app#{ nodePath .sep } uploads#{ nodePath .sep }#{ self .collectionName } "
588
-
588
+
589
589
unless _ .isString sp
590
590
throw new Meteor.Error 400 , " [FilesCollection.#{ self .collectionName } ] \" storagePath\" function must return a String!"
591
591
@@ -673,7 +673,7 @@ class FilesCollection
673
673
userId :
674
674
type : String
675
675
optional : true
676
- updatedAt :
676
+ updatedAt :
677
677
type : Date
678
678
optional : true
679
679
versions :
@@ -813,7 +813,7 @@ class FilesCollection
813
813
814
814
uris = uri .split ' /'
815
815
if uris .length is 3
816
- params =
816
+ params =
817
817
query : if request ._parsedUrl .query then JSON .parse (' {"' + decodeURI (request ._parsedUrl .query ).replace (/ "/ g , ' \\ "' ).replace (/ &/ g , ' ","' ).replace (/ =/ g ,' ":"' ) + ' "}' ) else {}
818
818
_id : uris[0 ]
819
819
version : uris[1 ]
@@ -840,7 +840,7 @@ class FilesCollection
840
840
version = ' original'
841
841
_file = _file .split (' ?' )[0 ]
842
842
843
- params =
843
+ params =
844
844
query : if request ._parsedUrl .query then JSON .parse (' {"' + decodeURI (request ._parsedUrl .query ).replace (/ "/ g , ' \\ "' ).replace (/ &/ g , ' ","' ).replace (/ =/ g ,' ":"' ) + ' "}' ) else {}
845
845
file : _file
846
846
_id : _file .split (' .' )[0 ]
@@ -862,7 +862,7 @@ class FilesCollection
862
862
_methods[self ._methodNames ._Remove ] = (selector ) ->
863
863
check selector, Match .OneOf String , Object
864
864
console .info " [FilesCollection] [Unlink Method] [.remove(#{ selector} )]" if self .debug
865
-
865
+
866
866
if self .allowClientCode
867
867
if self .onBeforeRemove and _ .isFunction self .onBeforeRemove
868
868
user = false
@@ -882,7 +882,7 @@ class FilesCollection
882
882
883
883
884
884
# Method used to receive "first byte" of upload
885
- # and all file's meta-data, so
885
+ # and all file's meta-data, so
886
886
# it won't be transferred with every chunk
887
887
# Basically it prepares everything
888
888
# So user can pause/disconnect and
@@ -1087,7 +1087,7 @@ class FilesCollection
1087
1087
{mime , ext } = fileType buf
1088
1088
catch error
1089
1089
if not mime or not _ .isString mime
1090
- mime = ' application/octet-stream'
1090
+ mime = ' application/octet-stream'
1091
1091
return mime
1092
1092
1093
1093
###
@@ -1113,16 +1113,16 @@ class FilesCollection
1113
1113
@returns {Object}
1114
1114
###
1115
1115
_getUser : (http ) ->
1116
- result =
1116
+ result =
1117
1117
user : -> return null
1118
1118
userId : null
1119
-
1119
+
1120
1120
if Meteor .isServer
1121
1121
if http
1122
1122
mtok = null
1123
1123
if http .request .headers [' x-mtok' ]
1124
1124
mtok = http .request .headers [' x-mtok' ]
1125
- else
1125
+ else
1126
1126
cookie = http .request .Cookies
1127
1127
if cookie .has ' x_mtok'
1128
1128
mtok = cookie .get ' x_mtok'
@@ -1298,7 +1298,7 @@ class FilesCollection
1298
1298
FSName = if @namingFunction then @ namingFunction () else fileId
1299
1299
pathParts = url .split (' /' )
1300
1300
fileName = if (opts .name or opts .fileName ) then (opts .name or opts .fileName ) else pathParts[pathParts .length - 1 ] or FSName
1301
-
1301
+
1302
1302
{extension , extensionWithDot } = @ _getExt fileName
1303
1303
opts .meta ?= {}
1304
1304
opts .path = " #{ @storagePath }#{ nodePath .sep }#{ FSName}#{ extensionWithDot} "
@@ -1776,7 +1776,7 @@ class FilesCollection
1776
1776
1777
1777
else if FileReaderSync
1778
1778
fileReader = new FileReaderSync
1779
-
1779
+
1780
1780
self .emitEvent ' sendChunk' , [{
1781
1781
data : {
1782
1782
bin : fileReader .readAsDataURL (chunk).split (' ,' )[1 ]
@@ -1787,7 +1787,7 @@ class FilesCollection
1787
1787
self .emitEvent ' end' , [' File API is not supported in this Browser!' ]
1788
1788
return
1789
1789
1790
- upload : ->
1790
+ upload : ->
1791
1791
if @result .onPause .get ()
1792
1792
return
1793
1793
@@ -1870,13 +1870,13 @@ class FilesCollection
1870
1870
opts .file .meta = fixJSONStringify opts .file .meta if opts .file ? .meta
1871
1871
HTTP .call ' POST' , " #{ @collection .downloadRoute } /#{ @collection .collectionName } /__upload" , {
1872
1872
data : opts
1873
- headers :
1873
+ headers :
1874
1874
' x-start' : ' 1'
1875
1875
' x-mtok' : Meteor .connection ? ._lastSessionId or null
1876
1876
}, handleStart
1877
1877
return
1878
1878
1879
- pipe : (func ) ->
1879
+ pipe : (func ) ->
1880
1880
@pipes .push func
1881
1881
return @
1882
1882
@@ -2028,7 +2028,7 @@ class FilesCollection
2028
2028
files .forEach (file) ->
2029
2029
self .unlink file
2030
2030
return
2031
-
2031
+
2032
2032
if @onAfterRemove
2033
2033
self = @
2034
2034
docs = files .fetch ()
@@ -2310,7 +2310,7 @@ class FilesCollection
2310
2310
http .response .setHeader ' Content-Range' , " bytes #{ reqRange .start } -#{ reqRange .end } /#{ vRef .size } "
2311
2311
stream = readableStream or fs .createReadStream vRef .path , {start : reqRange .start , end : reqRange .end }
2312
2312
http .response .writeHead 206 if readableStream
2313
- stream .on (' open' , ->
2313
+ stream .on (' open' , ->
2314
2314
http .response .writeHead 206
2315
2315
return
2316
2316
).on (' error' , streamErrorHandler
@@ -2364,7 +2364,7 @@ formatFleURL = (fileRef, version = 'original') ->
2364
2364
else
2365
2365
return root + " #{ fileRef ._downloadRoute } /#{ fileRef ._collectionName } /#{ fileRef ._id } /#{ version} /#{ fileRef ._id }#{ ext} "
2366
2366
2367
- if Meteor .isClient
2367
+ if Meteor .isClient and Template ?
2368
2368
###
2369
2369
@locus Client
2370
2370
@TemplateHelper
@@ -2387,4 +2387,4 @@ if Meteor.isClient
2387
2387
Export the FilesCollection class
2388
2388
###
2389
2389
Meteor .Files = FilesCollection
2390
- ` export { FilesCollection }`
2390
+ ` export { FilesCollection }`
0 commit comments