Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

Download file response headers #274

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ public static JSObject downloadFile(PluginCall call, Context context, ProgressEm
return new JSObject() {
{
put("path", file.getAbsolutePath());
put("headers", buildResponseHeaders((CapacitorHttpUrlConnection) connection));
}
};
}
Expand Down
5 changes: 4 additions & 1 deletion ios/Plugin/HttpRequestHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ class HttpRequestHandler {
try FilesystemUtils.createDirectoryForFile(dest, true)

try fileManager.moveItem(at: location, to: dest)
call.resolve(["path": dest.absoluteString])
call.resolve([
"path": dest.absoluteString,
"headers": (response as? HTTPURLResponse)?.allHeaderFields
])
} catch let e {
call.reject("Unable to download file", "DOWNLOAD", e)
return
Expand Down
1 change: 1 addition & 0 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export interface HttpGetCookiesResult {
export interface HttpDownloadFileResult {
path?: string;
blob?: Blob;
headers?: HttpHeaders;
}

export interface HttpUploadFileResult extends HttpResponse {}
Expand Down