Inherits from NSObject
Declared in RKParamsAttachment.h
RKParamsAttachment.m

Overview

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.

Typically, interactions with the RKParamsAttachment are accomplished through the RKParams class and there shouldn’t be much need to deal directly with this class.

Tasks

Creating an Attachment

Working with the Attachment

  •   name

    The parameter name of this attachment in the multi-part document.

    property
  •   MIMEType

    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.

    property
  •   MIMEBoundary

    The MIME boundary string

    property
  •   filePath

    The complete path to the attached file on disk.

    property
  •   fileName

    The name of the attached file in the MIME stream

    property
  •   value

    The value that is set when initialized through initWithName:value:

    property
  • – open

    Open the attachment stream to begin reading. This will generate a MIME header and prepare the attachment for writing to an RKParams stream.

  • – length

    The length of the entire attachment including the MIME header and the body.

  • – MD5

    Calculate and return an MD5 checksum for the body of this attachment.

Input streaming

Properties

MIMEBoundary

The MIME boundary string

@property (nonatomic, readonly) NSString *MIMEBoundary

Declared In

RKParamsAttachment.h

MIMEType

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.

@property (nonatomic, retain) NSString *MIMEType

Discussion

Default: nil

Declared In

RKParamsAttachment.h

fileName

The name of the attached file in the MIME stream

@property (nonatomic, retain) NSString *fileName

Discussion

Default: The name of the file attached or nil if there is not one.

Declared In

RKParamsAttachment.h

filePath

The complete path to the attached file on disk.

@property (nonatomic, readonly) NSString *filePath

Declared In

RKParamsAttachment.h

name

The parameter name of this attachment in the multi-part document.

@property (nonatomic, retain) NSString *name

Declared In

RKParamsAttachment.h

value

The value that is set when initialized through initWithName:value:

@property (nonatomic, retain) id<> value

Declared In

RKParamsAttachment.h

Instance Methods

MD5

Calculate and return an MD5 checksum for the body of this attachment.

- (NSString *)MD5

Discussion

This works for simple values, NSData structures in memory, or by efficiently streaming a file and calculating an MD5.

Declared In

RKParamsAttachment.h

initWithName:data:

Returns a newly initialized attachment with a given parameter name and the data stored in an NSData object.

- (id)initWithName:(NSString *)name data:(NSData *)data

Parameters

name

The parameter name of this attachment in the multi-part document.

data

The data that is used to create the attachment body.

Return Value

An initialized attachment with the given name and data.

Declared In

RKParamsAttachment.h

initWithName:file:

Returns a newly initialized attachment with a given parameter name and the data stored on disk at the given file path.

- (id)initWithName:(NSString *)name file:(NSString *)filePath

Parameters

name

The parameter name of this attachment in the multi-part document.

filePath

The complete path of a file to use its data contents as the attachment body.

Return Value

An initialized attachment with the name and the contents of the file at the path given.

Declared In

RKParamsAttachment.h

initWithName:value:

Returns a newly initialized attachment with a given parameter name and value.

- (id)initWithName:(NSString *)name value:(id<NSObject>)value

Parameters

name

The parameter name of this attachment in the multi-part document.

value

A value that is used to create the attachment body

Return Value

An initialized attachment with the given name and value.

Declared In

RKParamsAttachment.h

length

The length of the entire attachment including the MIME header and the body.

- (NSUInteger)length

Return Value

Unsigned integer of the MIME header and the body.

Declared In

RKParamsAttachment.h

open

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

Declared In

RKParamsAttachment.h

read:maxLength:

Read the attachment body in a streaming fashion for NSInputStream.

- (NSUInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len

Parameters

buffer

A data buffer. The buffer must be large enough to contain the number of bytes specified by len.

len

The maximum number of bytes to read.

Return Value

A number indicating the outcome of the operation:

  • A positive number indicates the number of bytes read;
  • 0 indicates that the end of the buffer was reached;
  • A negative number means that the operation failed.

Declared In

RKParamsAttachment.h