Skip to content
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

[TiMOB-17253](3.3.x) iOS HTTClient send files with timestamp as name #5886

Merged
merged 1 commit into from
Jul 7, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 18 additions & 8 deletions iphone/Classes/TiNetworkHTTPClientProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "TiUtils.h"
#import "TiBase.h"
#import "TiApp.h"
#import "Mimetypes.h"

#define TI_HTTP_REQUEST_PROGRESS_INTERVAL 0.03f

Expand Down Expand Up @@ -168,27 +169,36 @@ -(void)send:(id)args
NSInteger dataIndex = 0;
form = [[[APSHTTPPostForm alloc] init] autorelease];
id arg = [args objectAtIndex:0];
if([arg isKindOfClass:[NSDictionary class]]) {
NSInteger timespamp = (NSInteger)[[NSDate date] timeIntervalSince1970];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo : timestamp

if ([arg isKindOfClass:[NSDictionary class]]) {
NSDictionary *dict = (NSDictionary*)arg;
for(NSString *key in dict) {
id value = [dict objectForKey:key];
if([value isKindOfClass:[TiBlob class]]|| [value isKindOfClass:[TiFile class]]) {
if ([value isKindOfClass:[TiBlob class]]|| [value isKindOfClass:[TiFile class]]) {
TiBlob *blob;
NSString *name;
NSString *mime;
if([value isKindOfClass:[TiBlob class]]) {
NSString *name = nil;
NSString *mime = nil;
if ([value isKindOfClass:[TiBlob class]]) {
blob = (TiBlob*)value;
if([blob path] != nil) {
name = [[blob path] lastPathComponent];
} else {
name = [NSString stringWithFormat:@"file%i", dataIndex++];
}
}else{
blob = [(TiFile*)value blob];
name = [[(TiFile*)value path] lastPathComponent];
}
mime = [blob mimeType];
if(mime != nil) {
NSString* extension = nil;
if (mime != nil) {
extension = [Mimetypes extensionForMimeType:mime];
}
if (name == nil) {
name = [NSString stringWithFormat:@"%i%i", dataIndex++, timespamp];
if (extension != nil) {
name = [NSString stringWithFormat:@"%@.%@", name, extension];
}
}
if (mime != nil) {
[form addFormData:[blob data] fileName:name fieldName:key contentType:mime];
} else {
[form addFormData:[blob data] fileName:name fieldName:key];
Expand Down