зеркало из https://github.com/github/AFNetworking.git
Re-ordering AFHTTPClient multipart proxy methods
This commit is contained in:
Родитель
e8d55c8896
Коммит
59039d6a83
|
@ -574,6 +574,21 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
|
|||
mimeType:(NSString *)mimeType
|
||||
error:(NSError * __autoreleasing *)error;
|
||||
|
||||
/**
|
||||
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
|
||||
|
||||
@param inputStream The input stream to be appended to the form data
|
||||
@param name The name to be associated with the specified input stream. This parameter must not be `nil`.
|
||||
@param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
|
||||
@param length The length of the specified input stream in bytes.
|
||||
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
|
||||
*/
|
||||
- (void)appendPartWithInputStream:(NSInputStream *)inputStream
|
||||
name:(NSString *)name
|
||||
fileName:(NSString *)fileName
|
||||
length:(unsigned long long)length
|
||||
mimeType:(NSString *)mimeType;
|
||||
|
||||
/**
|
||||
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
|
||||
|
||||
|
@ -607,21 +622,6 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
|
|||
- (void)appendPartWithHeaders:(NSDictionary *)headers
|
||||
body:(NSData *)body;
|
||||
|
||||
/**
|
||||
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
|
||||
|
||||
@param inputStream The input stream to be appended to the form data
|
||||
@param name The name to be associated with the specified input stream. This parameter must not be `nil`.
|
||||
@param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
|
||||
@param length The length of the specified input stream in bytes.
|
||||
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
|
||||
*/
|
||||
- (void)appendPartWithInputStream:(NSInputStream *)inputStream
|
||||
name:(NSString *)name
|
||||
fileName:(NSString *)fileName
|
||||
length:(unsigned long long)length
|
||||
mimeType:(NSString *)mimeType;
|
||||
|
||||
/**
|
||||
Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
|
||||
|
||||
|
|
|
@ -873,6 +873,32 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
|
|||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void)appendPartWithInputStream:(NSInputStream *)inputStream
|
||||
name:(NSString *)name
|
||||
fileName:(NSString *)fileName
|
||||
length:(unsigned long long)length
|
||||
mimeType:(NSString *)mimeType
|
||||
{
|
||||
NSParameterAssert(name);
|
||||
NSParameterAssert(fileName);
|
||||
NSParameterAssert(mimeType);
|
||||
|
||||
NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
|
||||
[mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
|
||||
[mutableHeaders setValue:mimeType forKey:@"Content-Type"];
|
||||
|
||||
|
||||
AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init];
|
||||
bodyPart.stringEncoding = self.stringEncoding;
|
||||
bodyPart.headers = mutableHeaders;
|
||||
bodyPart.body = inputStream;
|
||||
|
||||
bodyPart.bodyContentLength = length;
|
||||
|
||||
[self.bodyStream appendHTTPBodyPart:bodyPart];
|
||||
}
|
||||
|
||||
- (void)appendPartWithFileData:(NSData *)data
|
||||
name:(NSString *)name
|
||||
fileName:(NSString *)fileName
|
||||
|
@ -914,31 +940,6 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
|
|||
[self.bodyStream appendHTTPBodyPart:bodyPart];
|
||||
}
|
||||
|
||||
- (void)appendPartWithInputStream:(NSInputStream *)inputStream
|
||||
name:(NSString *)name
|
||||
fileName:(NSString *)fileName
|
||||
length:(unsigned long long)length
|
||||
mimeType:(NSString *)mimeType
|
||||
{
|
||||
NSParameterAssert(name);
|
||||
NSParameterAssert(fileName);
|
||||
NSParameterAssert(mimeType);
|
||||
|
||||
NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
|
||||
[mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
|
||||
[mutableHeaders setValue:mimeType forKey:@"Content-Type"];
|
||||
|
||||
|
||||
AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init];
|
||||
bodyPart.stringEncoding = self.stringEncoding;
|
||||
bodyPart.headers = mutableHeaders;
|
||||
bodyPart.body = inputStream;
|
||||
|
||||
bodyPart.bodyContentLength = length;
|
||||
|
||||
[self.bodyStream appendHTTPBodyPart:bodyPart];
|
||||
}
|
||||
|
||||
- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
|
||||
delay:(NSTimeInterval)delay
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче