Ruby on Rails 3 Get Dropbox folder contents - ruby-on-rails

I am trying to develop an app which will retrieve a list of files and folders inside a specific Dropbox folder (from a user-specified folder). What would be the best way around doing this? Possibly some code snipplets if possible as I am still new to Rails.

Related

Download File from Dropbox folder in Rails application

I am trying and failing to download a single file from a "open for public" dropbox folder which a 3rd party created for others to use. I am trying to use this within my Ruby On Rails Application (file is changing but folder stays the same all the time).
I want to:
List all files in that public folder
Make sure that there is only this one file
... and this file has the appropriate filename (ending in .xlsx in my case -> an Excel file)
Download the file (e.g. using RestClient gem)
Save as an attachment to a new database record (Record is existing already and is used inside the app)
Thanks for any hints on how to proceed here! I Than plan to update the file with a cron-job daily.
Its kind of an API to the public :-)
Thought there must be a simple gem to interact with dropbox folders but couldnt't find any.
I used Rest-Client to open the dropbox folder and Nokogiri to parse the content but cant work through the glibberish produced. I gave up after an hour of work and decided to ask here!
Dropbox does offer a public Dropbox API, but it doesn't offer an official SDK for Ruby in particular, but you can either use the Dropbox API HTTPS endpoints directly, or via a third party library if there is one that works for your use case.
Exactly how you would accomplish this would depend on the specifics of the scenario so you may want to read through some guides first to get started, e.g.: Getting Started and File Access.
For instance, depending on how you have access to the content (e.g., directly via a folder in a connected account, or via a shared link, etc.) some of the following endpoints may be useful:
https://www.dropbox.com/developers/documentation/http/documentation#files-download
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-continue
https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_metadata
https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file
The Dropbox API v2 Explorer can also be a useful tool for trying out Dropbox API calls.

Extract ZIP and move all files to parent directory

I'm only just getting started with Yeoman, trying to create a Generator that downloads WordPress, unzips it, and then proceeds to download my own WordPress starter theme.
The problem I'm having is that when I extract the latest.zip from wordpress.org (using this.extract()) it contains a wordpress/ directory resulting in my directory structure being my-project/wordpress/ rather than my-project/.
I've tried moving, copying and deleting the wordpress/ directory with various degrees of success; using this.fs.copy() I actually managed to get the files in the correct folder, but when trying to delete the original wordpress/ directory the user has to confirm deletion of every single file (not ideal). When I tried this.fs.move() I had to confirm each and every move instead.
I've found similar gulp/node.js questions on here, but I would prefer to use Yeoman's built in this.fs API.
Please note that I am aware of YEOPress but this is mostly for learnig purposes.
I ended up using the Node Package fs-extra instead as it deletes or moves without confirmation.

Scan directory for file names in MVC

I'm developing a MVC5 web app, hosted through azure, that lets you manage your movies (it's just for myself at the moment). I'm trying to find a way to scan a local folder on the users pc for a list of file names. I do realise the security/permissions issues I might run into. I do not need the file uploaded, only the full file name.
It would work by the user being able to select a folder where they store their movies and it will take in all the file names, including the ones in any sub directories.
I tried a multiple file upload form but quickly ran into issues with the max request limit which I tried messing around with but it proved redundant in the end. I can settle for the user selecting multiple files but would rather it done the directory way.
I know this might prove impossible in the end but any help would be greatly appreciated.

How to migrate files a Dropbox app folder to another?

I have a chess app which can load and save chess records (PGN files) via Dropbox. The Dropbox access permission was all folders (which was popular in the old days). Recently, many users are writing to me for their concern of letting a chess app to access all Dropbox folders. So I am going to limit my app to a single app folder, i.e.: inside a Dropbox/Apps/Chess folder.
The question is, what is the proper way for the my app to migrate files from other folders to this Dropbox/Apps/Chess folder? As I will switch Dropbox API key during the process, how can I minimize the trouble for the users.

Keeping GoogleDrive files in sync with local files

I'm integrating Google Drive into an iOS app with the SDK, (which works great, thank you) and I would like to keep a set of files on Google Drive in sync with files on the device. By this I mean: When a user renames or moves a file on their device, I'd like it to rename/move on the server. If a user renames a folder, I'd like to rename that folder on the server.
With other cloud services that use a path to identify files, I can generate the path to rename or move the files on the server whenever I need them. With Google Drive, this is not the case--I need a file ID to rename or move something. Is there a convenient way to get the file ID from a path? Will I have to store information from Google Drive in my app? Is there a recommended best practice for this situation? Thanks for any help!
As far as I can see, you can keep a list of file ID when initially you insert file into Google Drive. When you insert a file into Google Drive, it will return a file resource which contains the inserted file ID and it doesnt change unless you delete it.

Resources