How can I download photos from a URL of folder in dropbox - ruby-on-rails

I have a Rails application which is suppose to upload images from a Dropbox URL pointed to a folder. The folder contains the images. Application is suppose to upload all images present in folder.
The URL is somewhat like this
https://www.dropbox.com/sh/17fsm6bsnac1g4q/AADJ7B2L0OIrkSrc7YcG-OO9a?dl=0
I can see the images but how can I get the list of all images URL. I have tried parsing the URL by appending dl=1 which downloads the images.
URI.parse('https://www.dropbox.com/sh/17fsm6bsnac1g4q/AADJ7B2L0OIrkSrc7YcG-OO9a?dl=1).
How can I get the URL of all images. If I can not get URL of images then how can i download all images and them upload them.

If you are okay with just downloading everything, you can make a GET request to the dl=1 version of the link you have. This URL parameter is documented here. This will give you a zipped version of the folder which you can then unzip and use as necessary.
Dropbox doesn't offer a way to get links for each of the files in the linked folder, but you can use the Dropbox API to list the files and then download them individually. You can use the /2/files/list_folder endpoint and pass the shared link in as the shared_link parameter. That will give you a list of the items in the folder.
You can then use /2/sharing/get_shared_link_file to download any desired file(s), by passing in the shared link as the url parameter, and the relative path for the file as the path parameter.

Related

Need download file from URL in my custom path Programmatically by java in SWT

I am using below code to open url and download something from this url. After that downloaded file should be save in my path mentioned in second parameter.But by this code when i perform download, the download file saved on browser default setting path. How to save download file to my own path.
Program.launch(url,my path);
org.eclispe.swt.Program.launch(url,path) opens the default operating system executable associated with the url (the browser in your configuration). The second parameter is the working directory for the executable and has nothing to do with the download directory of your browser.
If you only want to download something from an url please look at how-to-download-and-save-a-file-from-internet-using-java.

Download all available (and new) files

I'm using NSURLSessionDownloadTask to download some .mov files from a web and storing them in my app.
Now what I'd like to achieve is to
download ALL files of certain type (in this case .mov) available on the page, without having to specify every file URL
download files ONLY if they are not already stored in my app.
Is there any way to achieve this?
You would have to scrape that html page to get all the urls (.mov) you are looking for. Either you can use NSXMLParser if you want to write your own or you can google some library.
When you download a file, persist some metadata (eg. name or some unique identifier) either in SQLite or CoreData, so that you can check if the file has already been downloaded.

Paperclip preview files before downloading, also generate share link

I am starting up with rails and was going thru the sharebox-tutorial.
Now is it possible with paperclip to first preview the uploaded files and then choose the download link, rather than the file directly being downloaded when link is clicked, as in the tutorial and elsewhere in the internet.
Also, what will be the method to generate a share link unique to every friend email.
While researching, i also found out that files should be uploaded in some other folder but public.
how is it different from storing the files in public folder with the url hashed. the hash url is still accessible when user is logged out.
UPDATE
the preview i am referring to should be after uploading.

Google Drive File Download URL

Is the only way to download a file through Google Drive through the download_url that is provided? I have the file_id and would like to make one simple call to download the file. Right now it looks like you have to make one call to fetch the file metadata and retrieve the download_url, then another to actually download the file. Is this the only way?
Also, the download_url is described as a "short lived url". How long will this url be available for?
Thanks
Using the download_url is the correct way to download a file from Drive. I'd strongly advise against trying to build the download urls yourself as the resulting code will be likely to break.
A download_url is usually available for hours, but instead of relying on that you should always retrieve the updated file before downloading a file from Drive. More information at this other question: How long does the Google Drive SDK "short lived" download URL exist for?

How to display image which is stored on s3 without storing on harddisk?

In my rails app I have used attachment_fu to upload images and stored it on s3.
I want to display these images on browser without retrieving it.
How can I display images by giving s3 path?
Thanks,
Jayashri
You just need to link to the correct S3 path for you images.
For public files they are in the format:
eg http://s3.amazonaws.com/[bucket]/[key]
If your content is private you'll need to create a signed url but all the SDKs and libraries make this easy.
Then use the url to display the images:
<img src="http://s3.amazonaws.com/mybucket/myfile.jpg" ... ></img>
It may help you to install the S3 organizer in Firefox so you can browser your directories. Then I believe the URL's are structured kinda like this...
http://BUCKET.s3.amazonaws.com/FOO/BAR.png

Resources