xref: /aosp_15_r20/external/curl/docs/cmdline-opts/remote-name.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerLong: remote-name
5*6236dae4SAndroid Build Coastguard WorkerShort: O
6*6236dae4SAndroid Build Coastguard WorkerHelp: Write output to file named as remote file
7*6236dae4SAndroid Build Coastguard WorkerCategory: important output
8*6236dae4SAndroid Build Coastguard WorkerAdded: 4.0
9*6236dae4SAndroid Build Coastguard WorkerMulti: per-URL
10*6236dae4SAndroid Build Coastguard WorkerSee-also:
11*6236dae4SAndroid Build Coastguard Worker  - remote-name-all
12*6236dae4SAndroid Build Coastguard Worker  - output-dir
13*6236dae4SAndroid Build Coastguard Worker  - remote-header-name
14*6236dae4SAndroid Build Coastguard WorkerExample:
15*6236dae4SAndroid Build Coastguard Worker  - -O https://example.com/filename
16*6236dae4SAndroid Build Coastguard Worker  - -O https://example.com/filename -O https://example.com/file2
17*6236dae4SAndroid Build Coastguard Worker---
18*6236dae4SAndroid Build Coastguard Worker
19*6236dae4SAndroid Build Coastguard Worker# `--remote-name`
20*6236dae4SAndroid Build Coastguard Worker
21*6236dae4SAndroid Build Coastguard WorkerWrite output to a local file named like the remote file we get. (Only the file
22*6236dae4SAndroid Build Coastguard Workerpart of the remote file is used, the path is cut off.)
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard WorkerThe file is saved in the current working directory. If you want the file saved
25*6236dae4SAndroid Build Coastguard Workerin a different directory, make sure you change the current working directory
26*6236dae4SAndroid Build Coastguard Workerbefore invoking curl with this option or use --output-dir.
27*6236dae4SAndroid Build Coastguard Worker
28*6236dae4SAndroid Build Coastguard WorkerThe remote filename to use for saving is extracted from the given URL, nothing
29*6236dae4SAndroid Build Coastguard Workerelse, and if it already exists it is overwritten. If you want the server to be
30*6236dae4SAndroid Build Coastguard Workerable to choose the filename refer to --remote-header-name which can be used in
31*6236dae4SAndroid Build Coastguard Workeraddition to this option. If the server chooses a filename and that name
32*6236dae4SAndroid Build Coastguard Workeralready exists it is not overwritten.
33*6236dae4SAndroid Build Coastguard Worker
34*6236dae4SAndroid Build Coastguard WorkerThere is no URL decoding done on the filename. If it has %20 or other URL
35*6236dae4SAndroid Build Coastguard Workerencoded parts of the name, they end up as-is as filename.
36*6236dae4SAndroid Build Coastguard Worker
37*6236dae4SAndroid Build Coastguard WorkerYou may use this option as many times as the number of URLs you have.
38*6236dae4SAndroid Build Coastguard Worker
39*6236dae4SAndroid Build Coastguard WorkerBefore curl 8.10.0, curl returned an error if the URL ended with a slash,
40*6236dae4SAndroid Build Coastguard Workerwhich means that there is no filename part in the URL. Starting in 8.10.0,
41*6236dae4SAndroid Build Coastguard Workercurl sets the filename to the last directory part of the URL or if that also
42*6236dae4SAndroid Build Coastguard Workeris missing to `curl_response` (without extension) for this situation.
43