forked from darrylhthomas/StackMob_iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSMFile.m
More file actions
53 lines (47 loc) · 1.18 KB
/
Copy pathSMFile.m
File metadata and controls
53 lines (47 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// SMFile.m
// StackMobiOS
//
// Created by Ryan Connelly on 12/13/11.
// Copyright (c) 2011 StackMob, Inc. All rights reserved.
//
#import "SMFile.h"
#import "NSData+Base64.h"
@implementation SMFile
@synthesize data;
@synthesize name;
@synthesize contentType;
- (id) initWithFileName:(NSString *)name_ data:(NSData *)data_ contentType:(NSString *)contentType_
{
self = [super init];
if(self)
{
data = [data_ retain];
name = [name_ retain];
contentType = [contentType_ retain];
}
return self;
}
+ (id) fileWithName:(NSString *)name_ data:(NSData *)data_ contentType:(NSString *)contentType_
{
SMFile *file = [[SMFile alloc] initWithFileName:name_ data:data_ contentType:contentType_];
return [file autorelease];
}
- (id)JSON
{
return [NSString stringWithFormat:@"Content-Type: %@\n\
Content-Disposition: attachment; filename=%@\n\
Content-Transfer-Encoding: %@\n\n\
%@",
self.contentType,
self.name,
@"base64",
[self.data base64EncodedString]];
}
- (void)dealloc {
[data release];
[name release];
[contentType release];
[super dealloc];
}
@end