mirror of
https://github.com/apache/cordova-plugin-file-transfer.git
synced 2026-04-28 00:02:49 +08:00
[CB-4480] Using 64 bit ints to store file size
This commit is contained in:
committed by
Steven Gill
parent
9a125991f7
commit
fbbfff122a
+11
-11
@@ -49,8 +49,8 @@ NSString* const kFormBoundary = @"+++++org.apache.cordova.formBoundary";
|
||||
static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
|
||||
{
|
||||
UInt8* bytes = (UInt8*)[data bytes];
|
||||
NSUInteger bytesToWrite = [data length];
|
||||
NSUInteger totalBytesWritten = 0;
|
||||
long long bytesToWrite = [data length];
|
||||
long long totalBytesWritten = 0;
|
||||
|
||||
while (totalBytesWritten < bytesToWrite) {
|
||||
CFIndex result = CFWriteStreamWrite(stream,
|
||||
@@ -208,8 +208,8 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
|
||||
DLog(@"fileData length: %d", [fileData length]);
|
||||
NSData* postBodyAfterFile = [[NSString stringWithFormat:@"\r\n--%@--\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
NSUInteger totalPayloadLength = [postBodyBeforeFile length] + [fileData length] + [postBodyAfterFile length];
|
||||
[req setValue:[[NSNumber numberWithInteger:totalPayloadLength] stringValue] forHTTPHeaderField:@"Content-Length"];
|
||||
long long totalPayloadLength = [postBodyBeforeFile length] + [fileData length] + [postBodyAfterFile length];
|
||||
[req setValue:[[NSNumber numberWithUnsignedLongLong:totalPayloadLength] stringValue] forHTTPHeaderField:@"Content-Length"];
|
||||
|
||||
if (chunkedMode) {
|
||||
CFReadStreamRef readStream = NULL;
|
||||
@@ -535,7 +535,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
|
||||
if (uploadResponse != nil) {
|
||||
[uploadResult setObject:uploadResponse forKey:@"response"];
|
||||
}
|
||||
[uploadResult setObject:[NSNumber numberWithInt:self.bytesTransfered] forKey:@"bytesSent"];
|
||||
[uploadResult setObject:[NSNumber numberWithUnsignedLongLong:self.bytesTransfered] forKey:@"bytesSent"];
|
||||
[uploadResult setObject:[NSNumber numberWithInt:self.responseCode] forKey:@"responseCode"];
|
||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadResult];
|
||||
} else {
|
||||
@@ -665,9 +665,9 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
|
||||
[self updateProgress];
|
||||
}
|
||||
|
||||
- (void)updateBytesExpected:(NSInteger)newBytesExpected
|
||||
- (void)updateBytesExpected:(long long)newBytesExpected
|
||||
{
|
||||
DLog(@"Updating bytesExpected to %d", newBytesExpected);
|
||||
DLog(@"Updating bytesExpected to %lld", newBytesExpected);
|
||||
self.bytesExpected = newBytesExpected;
|
||||
[self updateProgress];
|
||||
}
|
||||
@@ -683,8 +683,8 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
|
||||
}
|
||||
NSMutableDictionary* downloadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
|
||||
[downloadProgress setObject:[NSNumber numberWithBool:lengthComputable] forKey:@"lengthComputable"];
|
||||
[downloadProgress setObject:[NSNumber numberWithInt:self.bytesTransfered] forKey:@"loaded"];
|
||||
[downloadProgress setObject:[NSNumber numberWithInt:self.bytesExpected] forKey:@"total"];
|
||||
[downloadProgress setObject:[NSNumber numberWithUnsignedLongLong:self.bytesTransfered] forKey:@"loaded"];
|
||||
[downloadProgress setObject:[NSNumber numberWithUnsignedLongLong:self.bytesExpected] forKey:@"total"];
|
||||
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:downloadProgress];
|
||||
[result setKeepCallbackAsBool:true];
|
||||
[self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
|
||||
@@ -697,8 +697,8 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
|
||||
NSMutableDictionary* uploadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
|
||||
|
||||
[uploadProgress setObject:[NSNumber numberWithBool:true] forKey:@"lengthComputable"];
|
||||
[uploadProgress setObject:[NSNumber numberWithInt:totalBytesWritten] forKey:@"loaded"];
|
||||
[uploadProgress setObject:[NSNumber numberWithInt:totalBytesExpectedToWrite] forKey:@"total"];
|
||||
[uploadProgress setObject:[NSNumber numberWithUnsignedLongLong:totalBytesWritten] forKey:@"loaded"];
|
||||
[uploadProgress setObject:[NSNumber numberWithUnsignedLongLong:totalBytesExpectedToWrite] forKey:@"total"];
|
||||
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadProgress];
|
||||
[result setKeepCallbackAsBool:true];
|
||||
[self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
|
||||
|
||||
Reference in New Issue
Block a user