/
RKParamsAttachment.h
86 lines (72 loc) · 2.12 KB
/
RKParamsAttachment.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// RKParamsAttachment.h
// RestKit
//
// Created by Blake Watters on 8/6/09.
// Copyright 2009 Two Toasters. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
* Models an individual part of a multi-part MIME document. These
* attachments are stacked together within the RKParams document to
* allow for uploading files via HTTP
*/
@interface RKParamsAttachment : NSObject {
NSString* _name;
NSString* _boundary;
NSString* _fileName;
NSString* _MIMEType;
@private
NSData* _MIMEHeader;
NSUInteger _MIMEHeaderLength;
NSInputStream* _bodyStream;
NSUInteger _bodyLength;
NSUInteger _length;
NSUInteger _delivered;
}
/**
* The parameter name of this attachment in the multi-part document
*/
@property (nonatomic, retain) NSString* name;
/**
* The name of the attached file in the MIME stream
* Defaults to the name of the file attached or nil if there is not one.
*/
@property (nonatomic, retain) NSString* fileName;
/**
* The MIME type of the attached file in the MIME stream. MIME Type will be
* auto-detected from the file extension of the attached file.
*
* Defaults to nil
*/
@property (nonatomic, retain) NSString* MIMEType;
/**
* The MIME boundary string
*/
@property (nonatomic, readonly) NSString* MIMEBoundary;
/**
* Initialize a new attachment with a given parameter name and a value
*/
- (id)initWithName:(NSString*)name value:(id<NSObject>)value;
/**
* Initialize a new attachment with a given parameter name and the data stored in an NSData object
*/
- (id)initWithName:(NSString*)name data:(NSData*)data;
/**
* Initialize a new attachment with a given parameter name and the data stored on disk at the given file path
*/
- (id)initWithName:(NSString*)name file:(NSString*)filePath;
/**
* Open the attachment stream to begin reading. This will generate a MIME header and prepare the
* attachment for writing to an RKParams stream
*/
- (void)open;
/**
* The length of the entire attachment (including the MIME Header and the body)
*/
- (NSUInteger)length;
/**
* Read the attachment body in a streaming fashion
*/
- (NSUInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len;
@end