URLDataProvider

Swift

@objc(PSPDFURLDataProvider)
public final class URLDataProvider : NSObject, DataProviding

The URLDataProvider manages automatic downloading of a file.

By default, downloads will use URLCache to cache downloads. The downloaded file is stored in a tmp directory (purged automatically by the system) while the cache is stored in the Caches directory (preserved except on low disk events)

If a custom targetURL is set and a file exists at this location, no download will be attempted. To ensure that the file is always up-to-date, delete the file at targetURL before allocating this class.

This class starts downloading the file as soon as it is initialized.

PSPDF_EXPORT(PSPDFURLDataProvider)

  • url

    URL is fixed at init time.

    Declaration

    Swift

    @objc(URL)
    public let url: URL
  • Location of the file on-disk, once download is complete. If targetURL is not set in the initializer, an automatic URL is generated. If a file exists there, downloading is skipped.

    Declaration

    Swift

    @objc(targetURL)
    public let targetURL: URL
  • The session configuration that is used to initiate the download.

    Declaration

    Swift

    @objc(sessionConfiguration)
    public let sessionConfiguration: URLSessionConfiguration?
  • Initialize class with an URL and an optional session configuration.

    Note

    URLSessionConfiguration cannot be serialized via NSCoder and is ignored.

    Declaration

    Swift

    @objc(initWithURL:sessionConfiguration:targetURL:)
    public init(url: URL, sessionConfiguration: URLSessionConfiguration? = nil, targetURL: URL? = nil)
  • Convenience initializer to improve Objective-C API.

    Declaration

    Swift

    @objc(initWithURL:)
    public convenience init(url: URL)
  • Undocumented

    Declaration

    Swift

    public override var description: String { get }
  • Undocumented

    Declaration

    Swift

    public static let supportsSecureCoding: Bool
  • Undocumented

    Declaration

    Swift

    public func encode(with coder: NSCoder)
  • Undocumented

    Declaration

    Swift

    required public init?(coder: NSCoder)
  • Undocumented

    Declaration

    Swift

    public func data() throws -> Data
  • Undocumented

    Declaration

    Swift

    public var size: UInt64 { get }
  • uid

    Undocumented

    Declaration

    Swift

    public var uid: String
  • Undocumented

    Declaration

    Swift

    public var error: Error?
  • Writing is not supported

    Declaration

    Swift

    public var additionalOperationsSupported: DataProvidingAdditionalOperations
  • Returns progress of the download task

    Declaration

    Swift

    public var progress: Progress?
  • Undocumented

    Declaration

    Swift

    public var signature: Data?
  • Undocumented

    Declaration

    Swift

    public func readData(withSize size: UInt64, atOffset offset: UInt64) throws -> Data
  • Converts a URL into a file name that can be safely stored on disk. While the path should be unique, conflicts might happen if the URL is too long and too similar.

    Declaration

    Swift

    @objc(defaultTargetURLForRemoteURL:)
    public class func defaultTargetURL(for remoteURL: URL) -> URL?