This repository was archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNibwareMIMEPart.m
More file actions
64 lines (47 loc) · 1.44 KB
/
NibwareMIMEPart.m
File metadata and controls
64 lines (47 loc) · 1.44 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
54
55
56
57
58
59
60
61
62
63
64
//
// NibwareMIMEPart.m
// pingle
//
// Created by Robert Sanders on 9/17/08.
// Copyright 2008 ViTrue, Inc.. All rights reserved.
//
#import "NibwareMIMEPart.h"
@implementation NibwareMIMEPart
@synthesize body;
@synthesize name;
@synthesize fileName;
@synthesize mimeType;
+ (NibwareMIMEPart*) mimePartFromFile:(NSString*)fileName mimeType:(NSString *)mimeType
{
return [[[NibwareMIMEPart alloc] initWithFile:fileName mimeType:mimeType] autorelease];
}
+ (NibwareMIMEPart*) mimePartFromData:(NSData*)data fileName:(NSString *)fileName mimeType:(NSString *)mimeType
{
return [[[NibwareMIMEPart alloc] initWithData:data fileName:fileName mimeType:mimeType] autorelease];
}
- (NibwareMIMEPart*) initWithFile:(NSString*)newfileName mimeType:(NSString *)newmimeType
{
return [self initWithData:[NSData dataWithContentsOfMappedFile:newfileName] fileName:newfileName mimeType:newmimeType];
}
- (NSString *)translateMimeType:(NSString*)type
{
if (type) return type;
return @"application/binary";
}
- (NibwareMIMEPart*) initWithData:(NSData*)data fileName:(NSString *)newfileName mimeType:(NSString *)newmimeType
{
self = [super init];
self.body = data;
self.fileName = newfileName;
self.name = newfileName;
self.mimeType = [self translateMimeType:mimeType];
return self;
}
- (void) dealloc {
[body release];
[name release];
[fileName release];
[mimeType release];
[super dealloc];
}
@end