5

I have been using Windows for a while, and with it there is a feature when you want to upload a photo (for example) to a website, you click on the "Choose File" in Chrome to upload a photo, a "File Explorer" opens, and instead of selecting a file from the hard drive you can paste a URL into the "File Explorer" and press open and it will download the file from the web to your temporary files, and use it to be uploaded.

Is there any way I can do that in Ubuntu 12.10?

Here is the windows example:
Upload from url via File Explorer

2
  • 1
    What website? Also I don't understand if you want to download or upload a file to that website? Can you be more explicit?
    – devius
    Dec 13, 2012 at 15:41
  • The site is Facebook, in windows you can do this: howto.cnet.com/8301-11310_39-57496509-285/… and and press open, it will then upload the photo to the website, in this case, Facebook. Dec 13, 2012 at 15:48

3 Answers 3

6

This functionality is implemented by the operating system's Open File dialog. Actually the site or the browser you use doesn't matter because this is operating system specific.

Gnome Open File dialog used in Ubuntu doesn't support this feature, however, the File Open dialog used in KDE is able to open HTTP URLs. I'm not sure what is the situation with support in other other desktop environments that run on Ubuntu.

4
  • Just tested this in KDE - indeed, it works in KDE just fine. Nice, I didn't know about this feature.
    – Sergey
    Dec 13, 2012 at 20:34
  • 1
    So basically, if the OP really really wants this feature he must install KDE and use it instead of the standard Unity session. Probably not the answer most users are looking for, but it is possible.
    – devius
    Dec 13, 2012 at 21:30
  • Well, KDE, XFCE, LXDE are all still "Ubuntu", albeit they're not default desktop environments. It just doesn't feel right to start an answer to "Feature X works in Windows, does it work in Ubuntu" with a categorical "No." Switching DEs just for this feature may be an overkill although I have to tell that if somebody needs configurability, features and options then KDE is a DE to check.
    – Sergey
    Dec 13, 2012 at 21:42
  • Well I am using Unity's dialog, or what ever comes default with Ubuntu 12.10. Thanks for the help, it sounds like it is not possible with this File Dialog box. Dec 13, 2012 at 22:59
1

And an obligatory command-line solution :) In the spirit of this answer: What is the command line equivalent of copying a file to clipboard? I wrote a simple Python script which accepts an URL to a resource as a parameter, downloads the file/page to a temporary location and copies the full file name to the clipboard. All that is left is to open Open File dialog and press Ctrl-V.

The script:

#!/usr/bin/python2

import os, tempfile, argparse, urllib

parser = argparse.ArgumentParser(description="Download a file from an URL, save it as a temporary file and copy a link to the file to clipboard")
parser.add_argument("url", help="The URL of a file to download")
args = parser.parse_args()

filename = tempfile.mktemp()
urllib.urlretrieve(args.url, filename)
os.system("echo %s|xclip  -i -selection clipboard" % filename)
print("File %s has been copied to clipboard, now open a File dialog and press Ctrl-V." % filename)

To use, create a directory called bin in your home directory, put the script there (I named it gimme) and set executable permission on it:

chmod +x ~/bin/gimme

Ahh, and you'll need xclip for it to work:

sudo apt-get install xclip

And here's how to use it:

gimme https://askubuntu.com/questions/228667/upload-file-from-url
File /tmp/tmpFXs7_S has been copied to clipboard, now open a File dialog and press Ctrl-V.
0

I'm not a Python coder, but I did want something like this that uploaded files. I tried Sergey's answer, but it didn't work for Facebook chat (possibly elsewhere, that's just where I tried it).

So I modified it a bit:

#!/usr/bin/python2

import os, tempfile, argparse, urllib, urlparse
from random import randint


parser = argparse.ArgumentParser(description="Download a file from a URL, save it as a temporary file and copy a link to the file to clipboard")
parser.add_argument("url", help="The URL of a file to download")
args = parser.parse_args()
path = urlparse.urlparse(args.url).path
urlext = os.path.splitext(path)[1]
filename = tempfile.mktemp() + urlext
urllib.urlretrieve(args.url, filename)
os.system("echo %s|xclip  -i -selection clipboard" % filename)
print("File %s has been copied to clipboard, now open a File dialog and press Ctrl-V." % filename)

Now it adds the file extension to the temp name, so FB identifies the proper mimetype and treats it appropriately.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .