How can I use wget to download a Confluence attachment without any plugins?
Results in an html file rather than the file itself. In my specific case I am trying to download a powerpoint file. If I enter the same URL in a browser, the browser will download the file correctly.
Try curl with the -O option. I had success using a command like this:
curl -O -uwilliam:password "http://confluence.mydomain.com/download/attachments/12345678/readme.txt"
Note that I stripped "?api=v2" from the download url. It wasn't necessary in my case and curl will use it in the file name.
This was with Confluence 4.3.7. I have no other version to test.
You did not explain that in the original question. You only asked how you use wget and I told you.
Now you've changed the question to something totally different, I can try again, although the answer is basically the same - hit the url for the file with wget and a username and password.
The problem you're having is probably that the url is wrong (download, not downloads) and you may need to add the api version to it by adding &api=2 to the end.
The saved file has the same filename as it the attachment (ie. filename.ppt). It won't open in powerpoint, but I can open it in notepad and it starts with "<!DOCTYPE html PUBLIC". If I manually change the extension to .html and open it in a browser, the page looks like a Confluence log-in page. I guess this means the username and password that is part of the wget command line isn't being transferred over to Confluence's login request?
In a new browser, entering the URL does ask me for the username and password (didn't notice it before since I was already logged into Confluence).
I solved it by using something that seems to be the case for other Atlassian products (ie JIRA)
You need to have the login info in the URL itself.
$client = new-object System.Net.WebClient
also remove any other stuff added after the extension of the file name in the URL
Was this ever resolved??
No. the command aboved marked solved does NOT work.
I am getting exactly the same issue.
Where file downloaded (supposed to be a .doc) starts with <!DOCTYPE html>
The file size is much smaller. And if I manually change the file to be .html, it goes into a cached page of what looks like the login page. So the credentials are not getting transferred.
Works fine on other site ie:
wget -O my.pdf "https://www.tutorialspoint.com/vbscript/vbscript_tutorial.pdf"
But this doesn't work
wget -O my.pdf --user user --password mypassword "http://tsm-wiki/download/attachments/38897186/Al%27s+comments.doc?version=1&modificationDate=1351755856000"
Any help is much appreciated.
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG