ResumableDownload
extends AbstractResumableTransfer
in package
Represents the state of a resumable multipart download.
This class can be serialized to/from JSON to persist download progress.
Table of Contents
Methods
- __construct() : mixed
- deleteResumeFile() : void
- fromFile() : self
- Load a resumable state from a file.
- fromJson() : self
- Deserialize a resumable download state from JSON format.
- getBucket() : string
- getConfig() : array<string|int, mixed>
- getCurrentSnapshot() : array<string|int, mixed>
- getDestination() : string
- getETag() : string
- getFixedPartSize() : int
- getInitialRequestResult() : array<string|int, mixed>
- getKey() : string
- getObjectSizeInBytes() : int
- getPartsCompleted() : array<string|int, mixed>
- getRequestArgs() : array<string|int, mixed>
- getResumeFilePath() : string
- getTemporaryFile() : string|null
- getTotalNumberOfParts() : int
- isResumeFile() : bool
- Check if a file path is a valid resume file.
- markPartCompleted() : void
- Mark a part as completed.
- toFile() : void
- Save the resumable state to a file.
- toJson() : string
- Serialize the resumable download state to JSON format.
- updateCurrentSnapshot() : void
- Update the current snapshot.
Methods
__construct()
public
__construct(string $resumeFilePath, array<string|int, mixed> $requestArgs, array<string|int, mixed> $config, array<string|int, mixed> $currentSnapshot, array<string|int, mixed> $initialRequestResult, array<string|int, mixed> $partsCompleted, int $totalNumberOfParts, string|null $temporaryFile, string $eTag, int $objectSizeInBytes, int $fixedPartSize, string $destination) : mixed
Parameters
- $resumeFilePath : string
- $requestArgs : array<string|int, mixed>
-
The request arguments used for the download
- $config : array<string|int, mixed>
-
The config used in the request
- $currentSnapshot : array<string|int, mixed>
-
The current progress snapshot
- $initialRequestResult : array<string|int, mixed>
-
The response from the initial request
- $partsCompleted : array<string|int, mixed>
-
Map of completed part numbers (partNo => true)
- $totalNumberOfParts : int
-
Total number of parts in the download
- $temporaryFile : string|null
-
Path to the temporary file being downloaded to
- $eTag : string
-
ETag of the S3 object for consistency verification
- $objectSizeInBytes : int
-
Total size of the object in bytes
- $fixedPartSize : int
-
Size of each part in bytes
- $destination : string
-
Final destination path for the downloaded file
deleteResumeFile()
public
deleteResumeFile([string|null $filePath = null ]) : void
Parameters
- $filePath : string|null = null
fromFile()
Load a resumable state from a file.
public
static fromFile(string $filePath) : self
Parameters
- $filePath : string
Return values
selffromJson()
Deserialize a resumable download state from JSON format.
public
static fromJson(string $json) : self
Parameters
- $json : string
-
JSON-encoded state
Tags
Return values
selfgetBucket()
public
getBucket() : string
Return values
stringgetConfig()
public
getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>getCurrentSnapshot()
public
getCurrentSnapshot() : array<string|int, mixed>
Return values
array<string|int, mixed>getDestination()
public
getDestination() : string
Return values
stringgetETag()
public
getETag() : string
Return values
stringgetFixedPartSize()
public
getFixedPartSize() : int
Return values
intgetInitialRequestResult()
public
getInitialRequestResult() : array<string|int, mixed>
Return values
array<string|int, mixed>getKey()
public
getKey() : string
Return values
stringgetObjectSizeInBytes()
public
getObjectSizeInBytes() : int
Return values
intgetPartsCompleted()
public
getPartsCompleted() : array<string|int, mixed>
Return values
array<string|int, mixed>getRequestArgs()
public
getRequestArgs() : array<string|int, mixed>
Return values
array<string|int, mixed>getResumeFilePath()
public
getResumeFilePath() : string
Return values
stringgetTemporaryFile()
public
getTemporaryFile() : string|null
Return values
string|nullgetTotalNumberOfParts()
public
getTotalNumberOfParts() : int
Return values
intisResumeFile()
Check if a file path is a valid resume file.
public
static isResumeFile(string $filePath) : bool
Parameters
- $filePath : string
Return values
boolmarkPartCompleted()
Mark a part as completed.
public
markPartCompleted(int $partNumber) : void
Parameters
- $partNumber : int
-
The part number to mark as completed
toFile()
Save the resumable state to a file.
public
toFile([string|null $filePath = null ]) : void
When a file path is not provided by default it will use
the resumeFilePath property.
Parameters
- $filePath : string|null = null
-
Path where the resume file should be saved
toJson()
Serialize the resumable download state to JSON format.
public
toJson() : string
Return values
string —JSON-encoded state
updateCurrentSnapshot()
Update the current snapshot.
public
updateCurrentSnapshot(array<string|int, mixed> $snapshot) : void
Parameters
- $snapshot : array<string|int, mixed>
-
The new snapshot data