mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-28 00:52:29 +03:00
Parse multipart response from AWS S3
This commit is contained in:
parent
d39797fdca
commit
15a62eab63
@ -117,6 +117,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"biscotto": "0.0.17",
|
||||
"formidable": "~1.0.14",
|
||||
"fstream": "0.1.24",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-cli": "~0.1.9",
|
||||
|
@ -2,6 +2,7 @@ fs = require 'fs'
|
||||
path = require 'path'
|
||||
|
||||
request = require 'request'
|
||||
formidable = require 'formidable'
|
||||
|
||||
module.exports = (grunt) ->
|
||||
{spawn, mkdir, rm, cp} = require('./task-helpers')(grunt)
|
||||
@ -107,10 +108,17 @@ module.exports = (grunt) ->
|
||||
cacheDirectory = getCachePath(version)
|
||||
rm(cacheDirectory)
|
||||
mkdir(cacheDirectory)
|
||||
cacheFile = path.join(cacheDirectory, 'atom-shell.zip')
|
||||
outputStream = fs.createWriteStream(cacheFile)
|
||||
outputStream.on 'close', -> callback(null, cacheFile)
|
||||
inputStream.pipe(outputStream)
|
||||
|
||||
form = new formidable.IncomingForm()
|
||||
form.uploadDir = cacheDirectory
|
||||
form.maxFieldsSize = 100 * 1024 * 1024
|
||||
form.on 'file', (name, file) ->
|
||||
cacheFile = path.join(cacheDirectory, 'atom-shell.zip')
|
||||
fs.renameSync(file.path, cacheFile)
|
||||
callback(null, cacheFile)
|
||||
form.parse response, (error) ->
|
||||
if error
|
||||
grunt.log.error("atom-shell #{version.cyan} failed to download")
|
||||
else
|
||||
if response.statusCode is 404
|
||||
grunt.log.error("atom-shell #{version.cyan} not found")
|
||||
|
Loading…
Reference in New Issue
Block a user