-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Can't upload file to s3 when file size is 0 #549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's hard to know what's changed here. Would you mind packaging this up as a pull request? That way you can also get credit for your work! |
@lsegal :OK |
Oh no, my code can upload empty file, but will lead to new problem: file size more than (4~5)mb seem will dead chunk and send large http request to s3.So i expect new solution. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
When file size is 0,i can't upload file to s3,Use wireshark tools i found sdk not send http request to s3.
my code:
s3obj.upload({Body: body}).send(cb);
i modify two code in l lib/s3/managed_upload.js file and it't work:
/**
@api private
*/
fillStream: function fillStream() {
var self = this;
if (self.activeParts >= self.queueSize) return;
var buf = self.body.read(self.partSize - self.partBuffer.length) ||
self.body.read();
if (buf) {
self.partBuffer = AWS.util.Buffer.concat([self.partBuffer, buf]);
self.totalChunkedBytes += buf.length;
}
if (self.partBuffer.length >= self.partSize) {
self.nextChunk(self.partBuffer.slice(0, self.partSize));
self.partBuffer = self.partBuffer.slice(self.partSize);
} else if (self.isDoneChunking) {
self.totalBytes = self.totalChunkedBytes;
if (self.partBuffer.length >= 0) { // change self.partBuffer.length > 0 to self.partBuffer.length >= 0
self.numParts++;
self.nextChunk(self.partBuffer);
}
self.partBuffer = new AWS.util.Buffer(0);
}
self.body.read(0);
}
/**
@api private
*/
adjustTotalBytes: function adjustTotalBytes() {
var self = this;
try { // try to get totalBytes
self.totalBytes = byteLength(self.body);
} catch (e) { }
// try to adjust partSize if we know payload length
if (self.totalBytes) {
var newPartSize = Math.ceil(self.totalBytes / self.maxTotalParts);
if (newPartSize > self.partSize) self.partSize = newPartSize;
}else if(self.totalBytes ==0){ //When self.totalBytes is 0, it's not boolean false; so care of here
self.totalBytes =0;
}
else {
self.totalBytes = undefined;
}
}
===========
Please update to github source files
The text was updated successfully, but these errors were encountered: