mirror of
https://github.com/bitwarden/ios.git
synced 2026-04-13 01:13:26 -05:00
40 lines
1.1 KiB
Swift
40 lines
1.1 KiB
Swift
import Foundation
|
|
import Networking
|
|
|
|
// MARK: - DirectFileUploadRequestModel
|
|
|
|
/// The request model for uploading a file directly.
|
|
///
|
|
struct DirectFileUploadRequestModel: MultipartFormRequestBody {
|
|
// MARK: Properties
|
|
|
|
/// String used as a boundary between parts.
|
|
var boundary: String { "--BWMobileFormBoundary\(date.timeIntervalSince1970 * 1000)" }
|
|
|
|
/// The date to use in the `boundary` for this request.
|
|
let date: Date
|
|
|
|
/// Array of parts included in the form.
|
|
let parts: [MultipartFormPart]
|
|
|
|
// MARK: Initialization
|
|
|
|
/// Creates a new `DirectFileUploadRequestModel`.
|
|
///
|
|
/// - Parameters:
|
|
/// - data: The data of the file being uploaded.
|
|
/// - date: The date to use in the `boundary` for this request.
|
|
/// - fileName: The name of the file being uploaded.
|
|
///
|
|
init(data: Data, date: Date = .now, fileName: String) {
|
|
self.date = date
|
|
parts = [
|
|
.file(
|
|
data: data,
|
|
name: "data",
|
|
fileName: fileName,
|
|
),
|
|
]
|
|
}
|
|
}
|