wget: how to download a served file keeping its name

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












A little IoT server returns a file, whose name is given by current date and time, to make it unique. The format is 2018.07.04.18.22.45.dat.



Asking for address XX.XX.XX.XX:5001/read in a browser (with browser cache disabled) the file is returned with its original name.



Using wget, alas, I cannot preserve the file name:
wget XX.XX.XX.XX:5001/read returns the proper content but with name read, read.1, read.2, etc.



Is there the possibility to collect it keeping the name, using wget or other commands?



ADDENDUM: using curl XX.XX.XX.XX:5001/read I obtain the raw content instead of the file.



ADDENDUM: as a imperfect workaround, I can generate a filename based on timestamp with wget -o $(date "+%Y.%m.%d-%H.%M.%S.%N.dat") XX.XX.XX.XX:5001/read. Of course it doesn't match the original filename.







share|improve this question





















  • Have you tried the --trust-server-names option?
    – ivanivan
    Jul 4 at 17:42










  • Yes, @ivanivan, I tried it but got read.X anyway...
    – Alex Poca
    Jul 4 at 17:47






  • 1




    Have you tried the --content-disposition option?
    – Nick ODell
    Jul 4 at 17:59










  • @Nick ODell, thank you! It works. Please move your comment to an answer so I can upvote it.
    – Alex Poca
    Jul 4 at 18:02










  • I also just found by chance the answer at unix.stackexchange.com/questions/394464/…. I completely missed it before.
    – Alex Poca
    Jul 4 at 18:05















up vote
1
down vote

favorite












A little IoT server returns a file, whose name is given by current date and time, to make it unique. The format is 2018.07.04.18.22.45.dat.



Asking for address XX.XX.XX.XX:5001/read in a browser (with browser cache disabled) the file is returned with its original name.



Using wget, alas, I cannot preserve the file name:
wget XX.XX.XX.XX:5001/read returns the proper content but with name read, read.1, read.2, etc.



Is there the possibility to collect it keeping the name, using wget or other commands?



ADDENDUM: using curl XX.XX.XX.XX:5001/read I obtain the raw content instead of the file.



ADDENDUM: as a imperfect workaround, I can generate a filename based on timestamp with wget -o $(date "+%Y.%m.%d-%H.%M.%S.%N.dat") XX.XX.XX.XX:5001/read. Of course it doesn't match the original filename.







share|improve this question





















  • Have you tried the --trust-server-names option?
    – ivanivan
    Jul 4 at 17:42










  • Yes, @ivanivan, I tried it but got read.X anyway...
    – Alex Poca
    Jul 4 at 17:47






  • 1




    Have you tried the --content-disposition option?
    – Nick ODell
    Jul 4 at 17:59










  • @Nick ODell, thank you! It works. Please move your comment to an answer so I can upvote it.
    – Alex Poca
    Jul 4 at 18:02










  • I also just found by chance the answer at unix.stackexchange.com/questions/394464/…. I completely missed it before.
    – Alex Poca
    Jul 4 at 18:05













up vote
1
down vote

favorite









up vote
1
down vote

favorite











A little IoT server returns a file, whose name is given by current date and time, to make it unique. The format is 2018.07.04.18.22.45.dat.



Asking for address XX.XX.XX.XX:5001/read in a browser (with browser cache disabled) the file is returned with its original name.



Using wget, alas, I cannot preserve the file name:
wget XX.XX.XX.XX:5001/read returns the proper content but with name read, read.1, read.2, etc.



Is there the possibility to collect it keeping the name, using wget or other commands?



ADDENDUM: using curl XX.XX.XX.XX:5001/read I obtain the raw content instead of the file.



ADDENDUM: as a imperfect workaround, I can generate a filename based on timestamp with wget -o $(date "+%Y.%m.%d-%H.%M.%S.%N.dat") XX.XX.XX.XX:5001/read. Of course it doesn't match the original filename.







share|improve this question













A little IoT server returns a file, whose name is given by current date and time, to make it unique. The format is 2018.07.04.18.22.45.dat.



Asking for address XX.XX.XX.XX:5001/read in a browser (with browser cache disabled) the file is returned with its original name.



Using wget, alas, I cannot preserve the file name:
wget XX.XX.XX.XX:5001/read returns the proper content but with name read, read.1, read.2, etc.



Is there the possibility to collect it keeping the name, using wget or other commands?



ADDENDUM: using curl XX.XX.XX.XX:5001/read I obtain the raw content instead of the file.



ADDENDUM: as a imperfect workaround, I can generate a filename based on timestamp with wget -o $(date "+%Y.%m.%d-%H.%M.%S.%N.dat") XX.XX.XX.XX:5001/read. Of course it doesn't match the original filename.









share|improve this question












share|improve this question




share|improve this question








edited Jul 4 at 18:00
























asked Jul 4 at 17:36









Alex Poca

1245




1245











  • Have you tried the --trust-server-names option?
    – ivanivan
    Jul 4 at 17:42










  • Yes, @ivanivan, I tried it but got read.X anyway...
    – Alex Poca
    Jul 4 at 17:47






  • 1




    Have you tried the --content-disposition option?
    – Nick ODell
    Jul 4 at 17:59










  • @Nick ODell, thank you! It works. Please move your comment to an answer so I can upvote it.
    – Alex Poca
    Jul 4 at 18:02










  • I also just found by chance the answer at unix.stackexchange.com/questions/394464/…. I completely missed it before.
    – Alex Poca
    Jul 4 at 18:05

















  • Have you tried the --trust-server-names option?
    – ivanivan
    Jul 4 at 17:42










  • Yes, @ivanivan, I tried it but got read.X anyway...
    – Alex Poca
    Jul 4 at 17:47






  • 1




    Have you tried the --content-disposition option?
    – Nick ODell
    Jul 4 at 17:59










  • @Nick ODell, thank you! It works. Please move your comment to an answer so I can upvote it.
    – Alex Poca
    Jul 4 at 18:02










  • I also just found by chance the answer at unix.stackexchange.com/questions/394464/…. I completely missed it before.
    – Alex Poca
    Jul 4 at 18:05
















Have you tried the --trust-server-names option?
– ivanivan
Jul 4 at 17:42




Have you tried the --trust-server-names option?
– ivanivan
Jul 4 at 17:42












Yes, @ivanivan, I tried it but got read.X anyway...
– Alex Poca
Jul 4 at 17:47




Yes, @ivanivan, I tried it but got read.X anyway...
– Alex Poca
Jul 4 at 17:47




1




1




Have you tried the --content-disposition option?
– Nick ODell
Jul 4 at 17:59




Have you tried the --content-disposition option?
– Nick ODell
Jul 4 at 17:59












@Nick ODell, thank you! It works. Please move your comment to an answer so I can upvote it.
– Alex Poca
Jul 4 at 18:02




@Nick ODell, thank you! It works. Please move your comment to an answer so I can upvote it.
– Alex Poca
Jul 4 at 18:02












I also just found by chance the answer at unix.stackexchange.com/questions/394464/…. I completely missed it before.
– Alex Poca
Jul 4 at 18:05





I also just found by chance the answer at unix.stackexchange.com/questions/394464/…. I completely missed it before.
– Alex Poca
Jul 4 at 18:05











1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Use wget --content-disposition <url>



Explanation: The Content-Disposition header can be used by a server to suggest a filename for a downloaded file. By default, wget uses the last part of the URL as the filename, but you can override this with --content-disposition, which uses the server's suggested name.






share|improve this answer





















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453465%2fwget-how-to-download-a-served-file-keeping-its-name%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    Use wget --content-disposition <url>



    Explanation: The Content-Disposition header can be used by a server to suggest a filename for a downloaded file. By default, wget uses the last part of the URL as the filename, but you can override this with --content-disposition, which uses the server's suggested name.






    share|improve this answer

























      up vote
      2
      down vote



      accepted










      Use wget --content-disposition <url>



      Explanation: The Content-Disposition header can be used by a server to suggest a filename for a downloaded file. By default, wget uses the last part of the URL as the filename, but you can override this with --content-disposition, which uses the server's suggested name.






      share|improve this answer























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        Use wget --content-disposition <url>



        Explanation: The Content-Disposition header can be used by a server to suggest a filename for a downloaded file. By default, wget uses the last part of the URL as the filename, but you can override this with --content-disposition, which uses the server's suggested name.






        share|improve this answer













        Use wget --content-disposition <url>



        Explanation: The Content-Disposition header can be used by a server to suggest a filename for a downloaded file. By default, wget uses the last part of the URL as the filename, but you can override this with --content-disposition, which uses the server's suggested name.







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jul 4 at 18:07









        Nick ODell

        8922819




        8922819






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453465%2fwget-how-to-download-a-served-file-keeping-its-name%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay