fix downloader
This commit is contained in:
parent
2a573db72e
commit
80a34d271a
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
test() ->
|
test() ->
|
||||||
{ok, Pid} = start_link(),
|
{ok, Pid} = start_link(),
|
||||||
Url = "https://codeload.github.com/genadyo/LivePhotoDemo/zip/refs/heads/master",
|
Url = "http://118.178.229.213:3000/anlicheng/ekfa/archive/main.tar.gz",
|
||||||
TargetDir = "/tmp/",
|
TargetDir = "/tmp/",
|
||||||
Ref = download(Pid, Url, TargetDir),
|
Ref = download(Pid, Url, TargetDir),
|
||||||
receive
|
receive
|
||||||
@ -146,6 +146,7 @@ receive_data0(ClientRef, TargetDir, DefaultFile) ->
|
|||||||
{hackney_response, ClientRef, {headers, Headers}} ->
|
{hackney_response, ClientRef, {headers, Headers}} ->
|
||||||
TargetFilename = extra_filename(Headers, DefaultFile),
|
TargetFilename = extra_filename(Headers, DefaultFile),
|
||||||
FullFilename = TargetDir ++ TargetFilename,
|
FullFilename = TargetDir ++ TargetFilename,
|
||||||
|
lager:debug("full name: ~p", [FullFilename]),
|
||||||
{ok, File} = file:open(FullFilename, [write, binary]),
|
{ok, File} = file:open(FullFilename, [write, binary]),
|
||||||
receive_data1(ClientRef, File)
|
receive_data1(ClientRef, File)
|
||||||
end.
|
end.
|
||||||
@ -173,8 +174,9 @@ extra_filename(Headers, Default) when is_list(Headers), is_list(Default) ->
|
|||||||
case proplists:get_value(<<"filename">>, Params) of
|
case proplists:get_value(<<"filename">>, Params) of
|
||||||
undefined ->
|
undefined ->
|
||||||
Default;
|
Default;
|
||||||
Filename ->
|
Filename0 ->
|
||||||
binary_to_list(Filename)
|
Filename = binary_to_list(Filename0),
|
||||||
|
string:trim(Filename, both, "\"")
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
Default
|
Default
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user