-
Creates a
DataRequestusingSession.defaultto retrieve the contents of the specifiedurlusing themethod,parameters,encoding, andheadersprovided.Declaration
Swift
public static func request(_ url: URLConvertible, method: HTTPMethod = .get, parameters: Parameters? = nil, encoding: ParameterEncoding = URLEncoding.default, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil) -> DataRequestParameters
urlThe
URLConvertiblevalue.methodThe
HTTPMethod,.getby default.parametersThe
Parameters,nilby default.encodingThe
ParameterEncoding,URLEncoding.defaultby default.headersThe
HTTPHeaders,nilby default.interceptorThe
RequestInterceptor,nilby default.Return Value
The created
DataRequest. -
Creates a
DataRequestusingSession.defaultto retrieve the contents of the specifiedurlusing themethod,parameters,encoding, andheadersprovided.Declaration
Swift
public static func request<Parameters: Encodable>(_ url: URLConvertible, method: HTTPMethod = .get, parameters: Parameters? = nil, encoder: ParameterEncoder = URLEncodedFormParameterEncoder.default, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil) -> DataRequestParameters
urlThe
URLConvertiblevalue.methodThe
HTTPMethod,.getby default.parametersThe
Encodableparameters,nilby default.encodingThe
ParameterEncoder,URLEncodedFormParameterEncoder.defaultby default.headersThe
HTTPHeaders,nilby default.interceptorThe
RequestInterceptor,nilby default.Return Value
The created
DataRequest. -
Creates a
DataRequestusingSession.defaultto execute the specifiedurlRequest.Declaration
Swift
public static func request(_ urlRequest: URLRequestConvertible, interceptor: RequestInterceptor? = nil) -> DataRequestParameters
urlRequestThe
URLRequestConvertiblevalue.interceptorThe
RequestInterceptor,nilby default.Return Value
The created
DataRequest.
-
Creates a
DownloadRequestusingSession.defaultto download the contents of the specifiedurlto the provideddestinationusing themethod,parameters,encoding, andheadersprovided.If
destinationis not specified, the download will be moved to a temporary location determined by Alamofire.Declaration
Swift
public static func download(_ url: URLConvertible, method: HTTPMethod = .get, parameters: Parameters? = nil, encoding: ParameterEncoding = URLEncoding.default, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil, to destination: DownloadRequest.Destination? = nil) -> DownloadRequestParameters
urlThe
URLConvertiblevalue.methodThe
HTTPMethod,.getby default.parametersThe
Parameters,nilby default.encodingThe
ParameterEncoding,URLEncoding.defaultby default.headersThe
HTTPHeaders,nilby default.interceptorThe
RequestInterceptor,nilby default.destinationThe
DownloadRequest.Destinationclosure used the determine the destination of the downloaded file.nilby default.Return Value
The created
DownloadRequest. -
Creates a
DownloadRequestusingSession.defaultto download the contents of the specifiedurlto the provideddestinationusing themethod, encodableparameters,encoder, andheadersprovided.Note
If
destinationis not specified, the download will be moved to a temporary location determined by Alamofire.Declaration
Swift
public static func download<Parameters: Encodable>(_ url: URLConvertible, method: HTTPMethod = .get, parameters: Parameters? = nil, encoder: ParameterEncoder = URLEncodedFormParameterEncoder.default, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil, to destination: DownloadRequest.Destination? = nil) -> DownloadRequestParameters
urlThe
URLConvertiblevalue.methodThe
HTTPMethod,.getby default.parametersThe
Encodableparameters,nilby default.encoderThe
ParameterEncoder,URLEncodedFormParameterEncoder.defaultby default.headersThe
HTTPHeaders,nilby default.interceptorThe
RequestInterceptor,nilby default.destinationThe
DownloadRequest.Destinationclosure used the determine the destination of the downloaded file.nilby default.Return Value
The created
DownloadRequest.
-
Creates a
DownloadRequestusingSession.defaultto execute the specifiedurlRequestand download the result to the provideddestination.Declaration
Swift
public static func download(_ urlRequest: URLRequestConvertible, interceptor: RequestInterceptor? = nil, to destination: DownloadRequest.Destination? = nil) -> DownloadRequestParameters
urlRequestThe
URLRequestConvertiblevalue.interceptorThe
RequestInterceptor,nilby default.destinationThe
DownloadRequest.Destinationclosure used the determine the destination of the downloaded file.nilby default.Return Value
The created
DownloadRequest.
-
Creates a
DownloadRequestusing theSession.defaultfrom theresumeDataproduced from a previousDownloadRequestcancellation to retrieve the contents of the original request and save them to thedestination.Note
If
destinationis not specified, the download will be moved to a temporary location determined by Alamofire.Note
On some versions of all Apple platforms (iOS 10 - 10.2, macOS 10.12 - 10.12.2, tvOS 10 - 10.1, watchOS 3 - 3.1.1),
resumeDatais broken on background URL session configurations. There’s an underlying bug in theresumeDatageneration logic where the data is written incorrectly and will always fail to resume the download. For more information about the bug and possible workarounds, please refer to the this Stack Overflow post.Declaration
Swift
public static func download(resumingWith resumeData: Data, interceptor: RequestInterceptor? = nil, to destination: DownloadRequest.Destination? = nil) -> DownloadRequestParameters
resumeDataThe resume
Data. This is an opaque blob produced byURLSessionDownloadTaskwhen a task is cancelled. See Apple’s documentation for more information.interceptorThe
RequestInterceptor,nilby default.destinationThe
DownloadRequest.Destinationclosure used to determine the destination of the downloaded file.nilby default.Return Value
The created
DownloadRequest.
-
Creates an
UploadRequestfor the givenData,URLRequestcomponents, andRequestInterceptor.Declaration
Swift
public static func upload(_ data: Data, to convertible: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil, fileManager: FileManager = .default) -> UploadRequestParameters
dataThe
Datato upload.convertibleURLConvertiblevalue to be used as theURLRequest‘sURL.methodHTTPMethodfor theURLRequest..postby default.headersHTTPHeadersvalue to be added to theURLRequest.nilby default.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby default.fileManagerFileManagerinstance to be used by the returnedUploadRequest..defaultinstance by default.Return Value
The created
UploadRequest. -
Creates an
UploadRequestfor the givenDatausing theURLRequestConvertiblevalue andRequestInterceptor.Declaration
Swift
public static func upload(_ data: Data, with convertible: URLRequestConvertible, interceptor: RequestInterceptor? = nil, fileManager: FileManager = .default) -> UploadRequestParameters
dataThe
Datato upload.convertibleURLRequestConvertiblevalue to be used to create theURLRequest.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby default.fileManagerFileManagerinstance to be used by the returnedUploadRequest..defaultinstance by default.Return Value
The created
UploadRequest.
-
Creates an
UploadRequestfor the file at the given fileURL, using aURLRequestfrom the provided components andRequestInterceptor.Declaration
Swift
public static func upload(_ fileURL: URL, to convertible: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil, fileManager: FileManager = .default) -> UploadRequestParameters
fileURLThe
URLof the file to upload.convertibleURLConvertiblevalue to be used as theURLRequest‘sURL.methodHTTPMethodfor theURLRequest..postby default.headersHTTPHeadersvalue to be added to theURLRequest.nilby default.interceptorRequestInterceptorvalue to be used by the returnedUploadRequest.nilby default.fileManagerFileManagerinstance to be used by the returnedUploadRequest..defaultinstance by default.Return Value
The created
UploadRequest. -
Creates an
UploadRequestfor the file at the given fileURLusing theURLRequestConvertiblevalue andRequestInterceptor.Declaration
Swift
public static func upload(_ fileURL: URL, with convertible: URLRequestConvertible, interceptor: RequestInterceptor? = nil, fileManager: FileManager = .default) -> UploadRequestParameters
fileURLThe
URLof the file to upload.convertibleURLRequestConvertiblevalue to be used to create theURLRequest.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby default.fileManagerFileManagerinstance to be used by the returnedUploadRequest..defaultinstance by default.Return Value
The created
UploadRequest.
-
Creates an
UploadRequestfrom theInputStreamprovided using aURLRequestfrom the provided components andRequestInterceptor.Declaration
Swift
public static func upload(_ stream: InputStream, to convertible: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil, fileManager: FileManager = .default) -> UploadRequestParameters
streamThe
InputStreamthat provides the data to upload.convertibleURLConvertiblevalue to be used as theURLRequest‘sURL.methodHTTPMethodfor theURLRequest..postby default.headersHTTPHeadersvalue to be added to theURLRequest.nilby default.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby default.fileManagerFileManagerinstance to be used by the returnedUploadRequest..defaultinstance by default.Return Value
The created
UploadRequest. -
Creates an
UploadRequestfrom the providedInputStreamusing theURLRequestConvertiblevalue andRequestInterceptor.Declaration
Swift
public static func upload(_ stream: InputStream, with convertible: URLRequestConvertible, interceptor: RequestInterceptor? = nil, fileManager: FileManager = .default) -> UploadRequestParameters
streamThe
InputStreamthat provides the data to upload.convertibleURLRequestConvertiblevalue to be used to create theURLRequest.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby default.fileManagerFileManagerinstance to be used by the returnedUploadRequest..defaultinstance by default.Return Value
The created
UploadRequest.
-
Creates an
UploadRequestfor the multipart form data built using a closure and sent using the providedURLRequestcomponents andRequestInterceptor.It is important to understand the memory implications of uploading
MultipartFormData. If the cumulative payload is small, encoding the data in-memory and directly uploading to a server is the by far the most efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be used for larger payloads such as video content.The
encodingMemoryThresholdparameter allows Alamofire to automatically determine whether to encode in-memory or stream from disk. If the content length of theMultipartFormDatais below theencodingMemoryThreshold, encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding technique was used.Declaration
Swift
public static func upload(multipartFormData: @escaping (MultipartFormData) -> Void, to url: URLConvertible, usingThreshold encodingMemoryThreshold: UInt64 = MultipartFormData.encodingMemoryThreshold, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil, fileManager: FileManager = .default) -> UploadRequestParameters
multipartFormDataMultipartFormDatabuilding closure.convertibleURLConvertiblevalue to be used as theURLRequest‘sURL.encodingMemoryThresholdByte threshold used to determine whether the form data is encoded into memory or onto disk before being uploaded.
MultipartFormData.encodingMemoryThresholdby default.methodHTTPMethodfor theURLRequest..postby default.headersHTTPHeadersvalue to be added to theURLRequest.nilby default.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby default.fileManagerFileManagerto be used if the form data exceeds the memory threshold and is written to disk before being uploaded..defaultinstance by default.Return Value
The created
UploadRequest. -
Creates an
UploadRequestusing aMultipartFormDatabuilding closure, the providedURLRequestConvertiblevalue, and aRequestInterceptor.It is important to understand the memory implications of uploading
MultipartFormData. If the cumulative payload is small, encoding the data in-memory and directly uploading to a server is the by far the most efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be used for larger payloads such as video content.The
encodingMemoryThresholdparameter allows Alamofire to automatically determine whether to encode in-memory or stream from disk. If the content length of theMultipartFormDatais below theencodingMemoryThreshold, encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding technique was used.Declaration
Swift
public static func upload(multipartFormData: @escaping (MultipartFormData) -> Void, with request: URLRequestConvertible, usingThreshold encodingMemoryThreshold: UInt64 = MultipartFormData.encodingMemoryThreshold, interceptor: RequestInterceptor? = nil, fileManager: FileManager = .default) -> UploadRequestParameters
multipartFormDataMultipartFormDatabuilding closure.requestURLRequestConvertiblevalue to be used to create theURLRequest.encodingMemoryThresholdByte threshold used to determine whether the form data is encoded into memory or onto disk before being uploaded.
MultipartFormData.encodingMemoryThresholdby default.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby default.fileManagerFileManagerto be used if the form data exceeds the memory threshold and is written to disk before being uploaded..defaultinstance by default.Return Value
The created
UploadRequest. -
Creates an
UploadRequestfor the prebuiltMultipartFormDatavalue using the providedURLRequestcomponents andRequestInterceptor.It is important to understand the memory implications of uploading
MultipartFormData. If the cumulative payload is small, encoding the data in-memory and directly uploading to a server is the by far the most efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be used for larger payloads such as video content.The
encodingMemoryThresholdparameter allows Alamofire to automatically determine whether to encode in-memory or stream from disk. If the content length of theMultipartFormDatais below theencodingMemoryThreshold, encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding technique was used.Declaration
Swift
public static func upload(multipartFormData: MultipartFormData, to url: URLConvertible, usingThreshold encodingMemoryThreshold: UInt64 = MultipartFormData.encodingMemoryThreshold, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil, fileManager: FileManager = .default) -> UploadRequestParameters
multipartFormDataMultipartFormDatainstance to upload.urlURLConvertiblevalue to be used as theURLRequest‘sURL.encodingMemoryThresholdByte threshold used to determine whether the form data is encoded into memory or onto disk before being uploaded.
MultipartFormData.encodingMemoryThresholdby default.methodHTTPMethodfor theURLRequest..postby default.headersHTTPHeadersvalue to be added to theURLRequest.nilby default.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby default.fileManagerFileManagerto be used if the form data exceeds the memory threshold and is written to disk before being uploaded..defaultinstance by default.Return Value
The created
UploadRequest. -
Creates an
UploadRequestfor the prebuiltMultipartFormDatavalue using the providingURLRequestConvertiblevalue andRequestInterceptor.It is important to understand the memory implications of uploading
MultipartFormData. If the cumulative payload is small, encoding the data in-memory and directly uploading to a server is the by far the most efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be used for larger payloads such as video content.The
encodingMemoryThresholdparameter allows Alamofire to automatically determine whether to encode in-memory or stream from disk. If the content length of theMultipartFormDatais below theencodingMemoryThreshold, encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding technique was used.Declaration
Swift
public static func upload(multipartFormData: MultipartFormData, with request: URLRequestConvertible, usingThreshold encodingMemoryThreshold: UInt64 = MultipartFormData.encodingMemoryThreshold, interceptor: RequestInterceptor? = nil, fileManager: FileManager = .default) -> UploadRequestParameters
multipartFormDataMultipartFormDatainstance to upload.requestURLRequestConvertiblevalue to be used to create theURLRequest.encodingMemoryThresholdByte threshold used to determine whether the form data is encoded into memory or onto disk before being uploaded.
MultipartFormData.encodingMemoryThresholdby default.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby default.fileManagerFileManagerinstance to be used by the returnedUploadRequest..defaultinstance by default.Return Value
The created
UploadRequest.
View on GitHub
Install in Dash
AF Enumeration Reference