-
Creates a
DataRequestusingSession.defaultto retrive 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 retrive 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
UploadRequestusingSession.defaultto upload the contents of thefileURLspecified using theurl,methodandheadersprovided.Declaration
Swift
public static func upload(_ fileURL: URL, to url: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil) -> UploadRequestParameters
fileURLThe
URLof the file to upload.urlThe
URLConvertiblevalue.methodThe
HTTPMethod,.postby default.headersThe
HTTPHeaders,nilby default.interceptorThe
RequestInterceptor,nilby default.Return Value
The created
UploadRequest. -
Creates an
UploadRequestusing theSession.defaultto upload the contents of thefileURLspecificed using theurlRequestprovided.Declaration
Swift
public static func upload(_ fileURL: URL, with urlRequest: URLRequestConvertible, interceptor: RequestInterceptor? = nil) -> UploadRequestParameters
fileURLThe
URLof the file to upload.urlRequestThe
URLRequestConvertiblevalue.interceptorThe
RequestInterceptor,nilby default.Return Value
The created
UploadRequest.
-
Creates an
UploadRequestusingSession.defaultto upload the contents of thedataspecified using theurl,methodandheadersprovided.Declaration
Swift
public static func upload(_ data: Data, to url: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil) -> UploadRequestParameters
dataThe
Datato upload.urlThe
URLConvertiblevalue.methodThe
HTTPMethod,.postby default.headersThe
HTTPHeaders,nilby default.interceptorThe
RequestInterceptor,nilby default.retryPoliciesThe
RetryPolicytypes,[]by default.Return Value
The created
UploadRequest. -
Creates an
UploadRequestusingSession.defaultto upload the contents of thedataspecified using theurlRequestprovided.Declaration
Swift
public static func upload(_ data: Data, with urlRequest: URLRequestConvertible, interceptor: RequestInterceptor? = nil) -> UploadRequestParameters
dataThe
Datato upload.urlRequestThe
URLRequestConvertiblevalue.interceptorThe
RequestInterceptor,nilby default.Return Value
The created
UploadRequest.
-
Creates an
UploadRequestusingSession.defaultto upload the content provided by thestreamspecified using theurl,methodandheadersprovided.Declaration
Swift
public static func upload(_ stream: InputStream, to url: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil) -> UploadRequestParameters
streamThe
InputStreamto upload.urlThe
URLConvertiblevalue.methodThe
HTTPMethod,.postby default.headersThe
HTTPHeaders,nilby default.interceptorThe
RequestInterceptor,nilby default.Return Value
The created
UploadRequest. -
Creates an
UploadRequestusingSession.defaultto upload the content provided by thestreamspecified using theurlRequestspecified.Declaration
Swift
public static func upload(_ stream: InputStream, with urlRequest: URLRequestConvertible, interceptor: RequestInterceptor? = nil) -> UploadRequestParameters
streamThe
InputStreamto upload.urlRequestThe
URLRequestConvertiblevalue.interceptorThe
RequestInterceptor,nilby 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 cummulative 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, usingThreshold encodingMemoryThreshold: UInt64 = MultipartFormData.encodingMemoryThreshold, fileManager: FileManager = .default, to url: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil) -> UploadRequestParameters
multipartFormDataMultipartFormDatabuilding closure.encodingMemoryThresholdByte threshold used to determine whether the form data is encoded into memory or onto disk before being uploaded.
MultipartFormData.encodingMemoryThresholdby default.fileManagerFileManagerto be used if the form data exceeds the memory threshold and is written to disk before being uploaded.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.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 cummulative 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, usingThreshold encodingMemoryThreshold: UInt64 = MultipartFormData.encodingMemoryThreshold, fileManager: FileManager = .default, with request: URLRequestConvertible, interceptor: RequestInterceptor? = nil) -> UploadRequestParameters
multipartFormDataMultipartFormDatabuilding closure.encodingMemoryThresholdByte threshold used to determine whether the form data is encoded into memory or onto disk before being uploaded.
MultipartFormData.encodingMemoryThresholdby default.fileManagerFileManagerto be used if the form data exceeds the memory threshold and is written to disk before being uploaded.requestURLRequestConvertiblevalue to be used to create theURLRequest.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby 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 cummulative 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, usingThreshold encodingMemoryThreshold: UInt64 = MultipartFormData.encodingMemoryThreshold, to url: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, interceptor: RequestInterceptor? = nil) -> UploadRequestParameters
multipartFormDataMultipartFormDatainstance to upload.encodingMemoryThresholdByte threshold used to determine whether the form data is encoded into memory or onto disk before being uploaded.
MultipartFormData.encodingMemoryThresholdby default.urlURLConvertiblevalue 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.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 cummulative 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, usingThreshold encodingMemoryThreshold: UInt64 = MultipartFormData.encodingMemoryThreshold, with request: URLRequestConvertible, interceptor: RequestInterceptor? = nil) -> UploadRequestParameters
multipartFormDataMultipartFormDatainstance to upload.encodingMemoryThresholdByte threshold used to determine whether the form data is encoded into memory or onto disk before being uploaded.
MultipartFormData.encodingMemoryThresholdby default.requestURLRequestConvertiblevalue to be used to create theURLRequest.interceptorRequestInterceptorvalue to be used by the returnedDataRequest.nilby default.Return Value
The created
UploadRequest.
View on GitHub
Install in Dash
AF Enumeration Reference