Skip to content

Commit

Permalink
Most of file upload on Cordova #253
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Oct 12, 2017
1 parent 34f6419 commit afae2a1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/files.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
corsHandler = (req, res, next) ->
if req.headers?.origin
res.setHeader 'Access-Control-Allow-Origin', req.headers.origin
res.setHeader 'Access-Control-Allow-Credentials', true
next()

@Files = FileCollection
resumable: true
resumableIndexName: 'files'
Expand All @@ -6,6 +12,29 @@
path: '/id/:_id'
lookup: (params, query) ->
_id: params._id
handler: corsHandler
,
method: 'post'
path: '/_resumable'
lookup: -> {}
handler: corsHandler
,
method: 'head'
path: '/_resumable'
lookup: -> {}
handler: corsHandler
,
method: 'options'
path: '/_resumable'
lookup: -> {}
handler: (req, res, next) ->
res.writeHead 200,
'Content-Type': 'text/plain'
'Access-Control-Allow-Origin': req.headers.origin
'Access-Control-Allow-Credentials': true
'Access-Control-Allow-Headers': 'x-auth-token, user-agent'
'Access-Control-Allow-Methods': 'GET, POST, HEAD, OPTIONS'
res.end()
]

if Meteor.isServer
Expand Down

0 comments on commit afae2a1

Please sign in to comment.