automattic / knox Goto Github PK
View Code? Open in Web Editor NEWS3 Lib
License: MIT License
S3 Lib
License: MIT License
I'm having difficulties incorporating this library into my app as it's a bit tricky to set up a mocked version. Any tips?
I haven't been able to get knox to work with buckets created outside of the US Virginia region. Knox puts the bucket name in the path, not the in hostname, which doesn't seem to work for other regions.
Take an bucket in Ireland for example. Knox tries this:
http://s3.amazonaws.com/ireland-region-test
But S3 expects this:
http://ireland-region-test.s3.amazonaws.com/
But for buckets in Virgina, both schemes work. This works:
http://s3.amazonaws.com/virginia-region-test
So does this:
http://virginia-region-test.s3.amazonaws.com/
I believe, adjusting knox to always put the bucketname in the hostname would fix this problem.
In aws php sdk, you can temporarily grant access for your ACL_PRIVATE files by generating links like:
$url = $s3->get_object_url('aws-php-sdk-test', $filename, '45 minutes');
Is it possible to generate these kind of links using knox?
If you use a bucket name containing uppercase characters, the exports.stringToSign(options)
call in auth.js
will return the resource name with uppercase characters, however Amazon waits this in strictly lowercase format in the signature.
Example:
Init knox with bucket name testUpperCase
StringToSign in knox:
GET
Tue, 01 Nov 2011 06:51:56 GMT
/testUpperCase/pic.jpg
Amazon response HTTP 403
:
<Error><Code>SignatureDoesNotMatch</Code> [...]
<StringToSign>GET
Tue, 01 Nov 2011 06:51:56 GMT
/testuppercase/pic.jpg</StringToSign> [...]
Hi,
it would be nice if you can release a new version of this awesome module
soon. Why? Because in the current version (0.0.9) this line [1] is missing
and therefore the whole Content-MD5
header does not work.
Thanks a lot!
[1] https://github.com/LearnBoost/knox/blob/master/lib/knox/client.js#L72
Listing buckets is relatively simple to do (client.get(''...)
), but it's currently impossible to add important parameters, like ?max-keys=n
. Being able to do this within Client.prototype.get
etc would probably be best.
We're trying to use fake-s3 (https://github.com/jubos/fake-s3) to mock S3 storage in unit tests. This way, one could use knox as a client to connect to a local fake-S3 server.
However, knox does not seem to support a user-specified port. (Within Client.prototype.request, options.port is never set).
Thanks!
When I use the example code:
var filename = 'image.jpg';
fs.readFile(filename, function(err, buf){
var req = client.put(filename, {
'Content-Length': buf.length
, 'Content-Type': 'text/plain'
});
req.on('response', function(res){
if (200 == res.statusCode) {
console.log('saved to %s', req.url);
}
});
req.end(buf);
});
And I get this error:
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: EPIPE, Broken pipe
at Client._writeImpl (net.js:138:14)
at Client._writeOut (net.js:427:25)
at Client.flush (net.js:506:24)
at Client._onWritable (net.js:584:12)
at IOWatcher.onWritable [as callback] (net.js:167:12)
Is that because I'm using the new node v0.4.0 ?
Anyone else having that problem?
Hi.
I was using Knox 0.9 on Nodejs v0.6.14 in production and it worked fine ( but with some memory leak issues ). So I've decided to update Nodejs to v0.8.4 and Knox before trying to solve this issues. When I updated just the Node I had some "socket hangup" errors so I saw an update on Knox ( version 0.11 ). I updated it but now nothing works. My code gets the UploadId from amazon before sending the parts to it using this line:
var request = client.request('POST', dest + '?uploads', { 'x-amz-acl' : 'public-read' });
Where "dest" is the file name.
But I'm always getting a status 400 from amazon and when I look the response I get the "Hostname/IP doesn't match certificate's altnames". Does anyone knows what it is?
Howdy guys. We are using knox to store virtual machine snapshots (200mb - 2gb) on Amazon s3, but running into a problem:
Error: ECONNRESET, Connection reset by peer
at Socket._writeImpl (net.js:159:14)
at Socket._writeOut (net.js:450:25)
at Socket.flush (net.js:529:24)
at Socket._onWritable (net.js:609:12)
at IOWatcher.onWritable [as callback] (net.js:188:12)
This is probably occurring because we are maxing out our connection, pushing close to 100Mbit a second for a few seconds before connection reset. Any idea how to throttle the upload to say 50Mbit/Sec?
Client uses http://bucket.s3.amazonaws.com/
instead of https://s3.amazonaws.com/bucket/
:-(
I'm trying to use knox to put some data on S3 but it always fails with a 501. Here's my code. Ignore the extra returns -- it's generated from coffee-script.
knox = require('knox');
s3 = knox.createClient({####SECRET####})
test_s3 = function() {
var buffer, request;
buffer = new Buffer(6);
buffer.write("Hello");
request = s3.put('test-key');
return request.on('response', function(response) {
console.log(response.statusCode);
return response.on('data', function(data) {
return console.log(data.toString('ascii'));
});
});
};
test_s3();
What I get on the console is this:
501
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NotImplemented</Code><Message>A header you provided implies functionality that is not implemented</Message><Header>Transfer-Encoding</Header><RequestId>67F400ED6D76C07A</RequestId><HostId>oyEU9C4gk/Kf6PQta2roQ2q0Pe1cfvi1BeoVUhsEPNV5qf/39ZmOVXCn5HqdCZtq</HostId></Error>
This doesn't make sense to me. Googling around, I found that S3 usually returns this response when you try and do some operation that shouldn't send any content, but you sent content anyway. But this is a put. It's supposed to have content. Looking through the request object, it appears that content length is set and the body is being written as it should be. So what is going wrong?
We used to in the 0.9 timeframe, but lost it in 0.10 when moving away from the use of path.join
.
See #76 for someone getting bit by this.
Wasn't sure if this was possible. I played around with some GET requests, but it hasn't been immediately obvious to me where the data is hiding. Is this even possible?
Hello,
is there any straightforward way to get progress support while uploading a file to S3?
Results from make test
:
..........
uncaught: AssertionError: 403 == 200
at /Users/thegoleffect/Documents/Projects/Spoondate/Spoondate.Website/node_modules/knox/test/knox.test.js:79:14
at ClientRequest. (/Users/thegoleffect/Documents/Projects/Spoondate/Spoondate.Website/node_modules/knox/lib/knox/client.js:199:7)
at ClientRequest.emit (events.js:42:17)
at HTTPParser.onIncoming (http.js:1299:9)
at HTTPParser.onHeadersComplete (http.js:87:31)
at Socket.ondata (http.js:1183:22)
at Socket._onReadable (net.js:654:27)
at IOWatcher.onReadable as callback
^C
Failures: 1
make: *** [test] Error 1
if I switch to 0.0.5, works just fine with the same auth file.
Now that it exists on S3, it should be implemented on Knox.
If I don't get beaten to it by somebody else, I'll try to make a patch.
http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?multiobjectdeleteapi.html
How to reproduce: Change your key or secret so you will get an authorization error.
node 0.4.11, knox 0.0.9
The following error is output when the Amazon response is received:
assert.js:93
throw new assert.AssertionError({
^
AssertionError: true == false
at IncomingMessage.<anonymous> (http.js:1341:9)
at IncomingMessage.emit (events.js:61:17)
at HTTPParser.onMessageComplete (http.js:133:23)
at Socket.ondata (http.js:1231:22)
at Socket._onReadable (net.js:683:27)
at IOWatcher.onReadable [as callback] (net.js:177:10)
Hi.
I was using the "pipe" method and saw that you guys implemented this on the 0.3 release. Trying to use the putStream I can only upload files with a size of about 1mb. Files larger than that gives me a 400 status Code from Amazon with the Socket Timeout error. Does anyone knows whats happening?
https://github.com/LearnBoost/knox/blob/master/lib/client.js#L230
I can't use content-length
as header
get()
works fine for me, but the URL produced from client.signedUrl
gives me an error:
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided. Check your key and signing method.
</Message>
<StringToSignBytes>
47 45 54 0a 0a 0a 31 33 31 30 32 38 32 33 37 31 0a 2f 70 68 6f 74 6f 2e 77 65 73 74 2e 73 70 79 2e 6e 65 74 2f 6f 72 69 67 69 6e 61 6c 2f 30 35 2f 30 35 38 65 33 36 62 62 64 61 31 65 36 34 63 65 62 30 39 63 66 31 37 64 63 63 35 61 61 62 61 31 2e 6a 70 67
</StringToSignBytes>
<RequestId>742F2DC7510AEB55</RequestId>
<HostId>
WiEAw4VFA57d/SEGbiGlmKccSvBUv/JnED0YHqTesizK79/GMgHavQCWFgnkXblj
</HostId>
<SignatureProvided>fjsaPEGJcL4Kr+pIGz5txlDrOH0=</SignatureProvided>
<StringToSign>
GET 1310282371 /photo.west.spy.net/original/03/038e36b3da1e34ceb09cf17dcf5aaba1.jpg
</StringToSign>
<AWSAccessKeyId>0F4GCGJRS56V9XG6XJR2</AWSAccessKeyId>
</Error>
Hello
I know, it's a bug in a blog article. But thechangelog is stating knox is in npm. Appears to b otherwise:
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm ERR! Error: 404 Not Found: knox
npm ERR! at IncomingMessage. (/usr/local/lib/node/.npm/npm/0.2.12-1/package/lib/utils/registry/request.js:136:16)
npm ERR! at IncomingMessage.emit (events:41:20)
npm ERR! at HTTPParser.onMessageComplete (http:107:23)
npm ERR! at Client.onData as ondata
npm ERR! at IOWatcher.callback (net:494:29)
npm ERR! at node.js:773:9
npm ERR! 404
npm ERR! 404 Looks like 'knox' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it.
npm ERR! 404 Note that you can also install from a tarball or local folder.
npm ERR! 404
I totally get the "low level" knox API should leave this kind of handling to the client. But I wanted to suggest that the "high level" knox S3 API handle the cases where AWS S3 returns a HTTP 307
status code.
The Amazon's S3 doc says:
If you create a bucket using <CreateBucketConfiguration>, applications that access your
bucket must be able to handle 307 redirects."
This happened to me when I used #53 a few minutes after creating a new bucket in AWS to use. Once DNS is sync'd with S3, the case is likely more rare.
Obviously there are "workarounds" for this, but wanted to bring it up since knox is working pretty well for me otherwise! Thanks!
I'm finding that putFile consistently reports a false success with a 307 redirect if the endpoint option is not specific to the region. Someone has already reported the issue with 307 being treated as success, but it should also be documented that you're not going to get very far without specifying the precise endpoint for your region rather than the generic one.
Are there any plans to inspect whether objects are public or private? Obviously this requires XML parsing, which is a nodejs wasteland, but it's sadly necessary in a quite a few cases.
Upgrading from node 0.4.0 to 0.4.1, there has been a change in fs.open that breaks knox.
fs.js:195
binding.open(path, stringToFlags(flags), mode, callback);
^
TypeError: Bad argument
at Object.open (fs.js:195:11)
at new (fs.js:786:6)
at Object.createReadStream (fs.js:741:10)
at Object.readFile (fs.js:49:23)
at Client.putFile (/usr/local/lib/node/.npm/knox/0.0.2/package/lib/knox/client.js:153:6)
Had a look at the line myself and admit I can't see what's up with, but I wrote a quick seperate file test and it worked fine, so can only assume it's coming from somewhere in knox
first of all thanks for all your great node-modules :)
unfortunately i'm having troubles with a custom endpoint set within the knox-client.
the response of aws says:
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
var client = knox.createClient({
key: *****
, secret: ****
, bucket: ****
, endpoint: 's3-eu-west-1.amazonaws.com'
});
client.get('/').on('response', function(res){
res.setEncoding('utf8');
res.on('data', function(chunk){
console.log(chunk);
});
}).end();
is there anything wrong with my usage of knox? the accessKey & token works with no custom endpoint set.
This functionality seems independent enough that offloading it to someone else, or pulling it out into its own package just for our own use, might be a good idea.
Would be nice to have CloudFront support for invalidating files.
var s3 = require('s3') // s3 is an initialized knox S3 Client instance
var fs = require('fs')
var file = '/Users/nrajlich/Pictures/avatar.jpg'; // This is a valid JPG file that does exist
var headers = {};
headers['Content-Type'] = 'image/jpeg';
var res = fs.createReadStream(file);
var s3req = s3.putStream(res, '/nate-avatar.jpg', headers, function(err, s3res){
if (err) throw err;
console.log(s3res.statusCode);
console.log(s3res.headers);
s3res.pipe(process.stdout, {end: false});
console.error('s3 callback', s3req.url);
});
s3req.on('progress', console.log);
Using knox v0.3.0, this script makes S3 return a 501 error code, with the following XML body:
<Error>
<Code>NotImplemented</Code>
<Message>A header you provided implies functionality that is not implemented</Message>
<Header>Transfer-Encoding</Header><RequestId>7A05E23CB3DBBD1E</RequestId>
<HostId>Dylx7eIcmXceZCEOZKmMxpGclu2i5bsdlV6pdyH8uAzNm+DAXPE/vdrFkFwFaHht</HostId>
</Error>
Not sure if this is misuse on my part or a problem with knox
, but it's kinda holding me up at the moment :)
Hi TJ,
Don't know the right place to ask howto questions for Knox [couldn't find a wiki/doc beyond the Readme.md...]
Simple question:
I want to write the output of a db query directly to S3 to use Cloudfront as my database cache. This does not involve an fs.readFile rather a db.find() query which I want to put the result to S3 as a JSON object.
Is this possible? or do I need to write it as a temporary file on my fs and then read/put it to S3?
Thanks.
Hi, trying to run knox to upload an image file into s3, and followed the tutorial and received a 400 error with invalid URI.
Here's the code:
var fs = require('fs');
var knox = require('knox');
var client = knox.createClient({
key: 'accessKeyGoesHere'
, secret: 'secretyKeyGoesHere'
, bucket: 'GSTest'
, endpoint: 'GSTest.s3-website-us-east-1.amazonaws.com'
});
fs.readFile('C:\Dev\Java\workspace\mobileservice\src\public\images\mockdata\425268bb7a292ce6af493680fe641ed0.jpg', function(err, buf){
console.log('File has been read, buffer length of file is:' + buf.length);
var req = client.put('/image.jpg', {
'Content-Length': buf.length
, 'Content-Type': 'text/plain'
});
req.on('response', function(res){
console.log('res.statusCode: ' + res.statusCode);
console.log('res.headers: ' + res.headers);
res.on('data', function(chunk){
console.log('chunk string: ' + chunk.toString());
});
if (200 == res.statusCode) {
console.log('saved to %s', req.url);
}
});
req.end(buf);
console.log('req.end finished');
res.send([{result: 'success'}]);
});
Any thoughts? When I output the req.url I get http://GirlSafariTest.s3-website-us-east-1.amazonaws.com\image.jpg with an opposite slash instead of http://GirlSafariTest.s3-website-us-east-1.amazonaws.com/image.jpg. Perhaps this is the problem... not sure what the error is.
I also tried an alternative method where I do not specify the endpoint, and ran into a signature match error.
Several commits have just been adding file extension -> mime type maps. Let's offload this to an external package and stay focused on the core problem of S3 requests.
This is more of a question than an issue. Will Knox be able to handle massive concurrency putting files on S3 w/o tweaking agent.maxSockets to be something greater than 5? If so, any suggestions/best practices for setting this number and/or other options for getting better perf. under heavy load?
Everything uploaded as planned and it showed up in S3 AWS console. I made sure permissions are set. When I double clicked the file, it takes me to nothing. Not sure what I am doing wrong here.
The local upload works.
if req.method == 'POST'
Knox = require 'knox'
S3 = Knox.createClient
key: CONFIG.amazon.key
secret: CONFIG.amazon.secret
bucket: CONFIG.amazon.s3
path = req.body.path || 'etc'
path = '/'+req.subdomain+'/'+path
files = []
rFiles = []
console.log req.files
_.each req.files, (file, k) -> files.push file
async.forEachLimit files, 6,
((file, cb) -> # Upload and move the files
if acceptableFile.indexOf(file.type) != -1
fullpath = BASEPATH+'/static/uploads'+path
filename = (file.path.split('/')[2]+'.'+file.name.substr(file.name.lastIndexOf('.')+1)).toLowerCase()
### Local copy
mkdir fullpath, (err) -> # recursively create dir
fs.link file.path, fullpath+'/'+filename, (err) ->
if err then console.log err
return
rFiles.push path+'/'+filename
fs.unlink file.path
cb()
return # mkdir
###
console.log file
S3.putFile file.path, path+'/'+file.name, (err, r) ->
if err
log.error "c/user.upload - Error uploading #{file.name} -> #{path+'/'+filename} to S3 - #{err.message}"
console.error err
rFiles.push null
fs.unlink file.path
cb err
return
if r.statusCode == 200
rPath = "https://#{CONFIG.amazon.s3}.s3.amazonaws.com#{path}/#{filename}"
log.info "c/user.upload - #{rPath} uploaded"
rFiles.push rPath
fs.unlink file.path
cb()
else
log.error "c/user.upload - Error uploading #{file.name} -> #{path+'/'+filename} to S3 - #{r.statusCode} error"
rFiles.push null
fs.unlink file.path
cb new Error r.statusCode
return
return),
((err) ->
if err
res.send 'Error uploading file'
return
res.send 'File uploaded'
return)
else
res.render BASEPATH+'/v/public/user/upload',
layout: null
path: req.query.path || 'etc'
next()
I don't have a good idea of what the problem is, but I'm getting a 403 on all objects in my bucket. Here's what I know:
Are there other details I could provide to narrow this down? Thanks.
Also, reimplement putFile
in terms of it.
All the existing pull requests go about this in a strange way. It should be as simple as
Client.prototype.putStream = function (stream, filename, headers, fn) {
var req = this.put(filename, headers);
stream.pipe(pipe);
// a bunch of code to hook up to the appropriate listeners and then call `fn` appropriately
};
Then we can reimplement putFile
to do a fs.stat
to get Content-Type
and Content-Length
headers before just proxying to putStream
.
lots of canvas related interactions are just with a Buffer
, resizing etc so it would be sweet to just PUT the buf
While inspecting the response
from putFile
, I see the newly generated URL in some nested properties. The outer-most url
property of the response is blank, though. Should this contain that URL, as well?
AwsJobHandler.prototype.putPsd = function (psd, callback) {
// the local temp path to the psd to put on aws
var localPsdPath = psd.temporaryPath;
// the base url address for this psd on aws
var basePsdUrl = '/' + psd.user + '/psd/' + psd._id + '.psd';
var req = this.client.putFile(localPsdPath, basePsdUrl, function (err, res) {
if (err || res.statusCode != 200)
return callback(new Error('aws upload failed'));
// this is blank
console.log(res.url);
// update the psd doc with new url
models.psd.update({ _id: psd._id }, { '$set': { url: basePsdUrl }});
return callback(basePsdUrl);
});
};
I'm trying to stream an octet-stream straight to S3. The octet-stream is an XHR file upload from the browser. I assumed that I could just stream the request into putStream and everything would just work, but alas no.
Here's my code:
client = knox.createClient({ ... });
if (req.headers['content-type'].match(/application\/octet-stream/i)) {
var filename = '/'+req.headers['x-file-name'];
client.putStream(req, filename, function(err, res){
// TODO: Catch errors
body = '{"success":"true"}'
res.writeHead(200,
{ 'Content-Type':'text/html'
, 'Content-Length':body.length
})
res.end(body)
});
}
And the error I receive:
TypeError: Bad argument
at Object.stat (fs.js:354:11)
at Client.putStream (knox/client.js:181:6)
Silly question:
Is it possible to upload by chunked content? I'm using knox with formidable and it would be great to just push the chunks as they are parsed.
Here's what I got after a fresh clone and doing git submodule update --init
(could be a useful hint in the README?):
tom% make test
.................
uncaught: AssertionError: 404 == 100
at /Users/tom/Documents/Code/knox/test/ns3.test.js:70:18
at ClientRequest.<anonymous> (lib/knox/client.js:160:7)
at ClientRequest.emit (events:27:15)
at HTTPParser.onIncoming (http:959:9)
at HTTPParser.onHeadersComplete (http:87:31)
at Client.onData [as ondata] (http:848:27)
at IOWatcher.callback (net:494:29)
at node.js:772:9
uncaught: Error: 'test .putFile()' timed out
at Timer.callback (/Users/tom/Documents/Code/knox/support/expresso/bin/expresso:746:43)
at node.js:772:9
Failures: 2
I'm using node v0.2.4 on Mac OS X.
Hi.
Thanks for the module, it helped me a lot in a feature that I'm developing in my product.
A thing that've noticing is that sometimes when the response.statusCode isn't 200 the nodeJS crashes at an exception:
assert.js:93
throw new assert.AssertionError({
^
AssertionError: true == false
at IncomingMessage. (http.js:1341:9)
at IncomingMessage.emit (events.js:61:17)
at HTTPParser.onMessageComplete (http.js:133:23)
at Socket.ondata (http.js:1231:22)
at Socket._onReadable (net.js:683:27)
at IOWatcher.onReadable as callback
Does anyone knows why this happens? Is there a way to catch that exception avoiding the server to crash?
Thanks a lot
Thiago
It's relatively simple to move files with knox, but it requires you to set Content-Length: 0 so that nodejs doesn't send a Transfer-Encoding header to S3, which will make S3 501.
Adding some documentation for this might save people some time:
client.put('0/0/0.png', {
'Content-Type': 'image/jpg',
'Content-Length': '0',
'x-amz-copy-source': '/test-tiles/0/0/0.png',
'x-amz-metadata-directive': 'REPLACE'
}).on('response', function(res) {
}).end();
to avoid sys
warnings
didn't have this when I wrote knox, but we should utilize it now
When running
make test
We get the error 'expresso' not found -- so we should add instructions in the Readme.md
:
git submodule init
git submodule update
Then, when you do run make test
, the following error occurs:
laptop@laptop ~/Public/knox $ make test
The "sys" module is now called "util". It should have a similar interface.
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
at Function.<anonymous> (module.js:376:11)
at Object.<anonymous> (/home/laptop/Public/knox/support/expresso/bin/expresso:127:24)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
Resolve if you could ๐
I've worked through numerous examples on this, but still receiving a SignatureDoesNotMatch error when I try to 'put()' a jpeg into S3.
I've used the amazon s3 signature testing tool to troubleshoot and identified a difference between the request I am sending and what amazon expects.
What the amazon test tool expects when I enter the hexcode returned in the StringToSign section,
PUT\n\nimage/jpeg\nThu, 29 Dec 2011 06:32:18 GMT\nx-amz-acl:public-read\n/girlsafaritest2\28.jpg
What I am seeing in console.log in the request object I send out to amazon via the put() call in Knox,
_header: 'PUT \28.jpg HTTP/1.1\r\nExpect: 100-continue\r\nx-amz-acl: public-r
ead\r\nContent-Length: 45800\r\nContent-Type: image/jpeg\r\nDate: Thu, 29 Dec 20
11 06:32:18 GMT\r\nHost: girlsafaritest2.s3.amazonaws.com\r\nAuthorization: AWS
AKIAJ3S7Y6CDASJHLUWA:Tm+8/ljOevwZnoV9sEzduo4rYhw=\r\nConnection: keep-alive\r\n
r\n'
Almost everything matches except I noticed that there are two differences, 1) - the \28.jpg (is the \ causing a problem?) and 2) Amazon expects \n while in the request it uses \r\n (is windows causing an issue? I am running nodejs/knox from Win7)
In case anyone wants to see the code I am using, here it is as well:
fs.readFile('./public/images/mockdata/28.jpg', function(err, buf){
console.log('readfile completed, length is: ' + buf.length);
var req = client.put('28.jpg', {
'Content-Length': buf.length
, 'Content-Type': 'image/jpeg'
});
console.log(req);
req.on('response', function(res){
console.log('[Response]:\n\r res.statusCode: ' + res.statusCode);
console.log('res.headers: ' + res.headers);
res.on('data', function(chunk){
console.log('chunk string: ' + chunk.toString());
});
if (200 == res.statusCode) {
console.log('saved to %s', req.url);
}
});
req.end(buf);
});
Appreciate any help anyone can provide!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.