Can RoR access and monitor an external hard drive on clients local maching? - ruby-on-rails

I am trying to build web based file archiving app (like Apple Time Machine) that watches an external hard drive and when ever a file/folder is added it writes the file path to a database that can be searched later. So if user added this folder "My Folder" on this date "04/16/12" to external HD "Drive 1" and needed to find that folder or its contents at a later date they could search the name, date or drive name and the corresponding results would be returned.
Is this possible with RoR or would I have to use another language or a combination of the two?

Ruby can access the local system, see here for some examples of Disk IO operations possible:
http://www.tutorialspoint.com/ruby/ruby_input_output.htm
Obviously, this means the ruby must be running on the local disk. In theory, RoR could be used along with vanilla ruby code for this purpose, so long as it was all running locally. Seems like a hassle to setup a web server simply for some software to use however.
See this question for a discussion of Ruby frameworks that aren't for web apps:
Ruby App MVC framework (not web)

No. Ruby on Rails is a web framework. You'll need to use something client-side such Objective-C, C++, or even Java.

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.

How can we integrate resource file with any translation management tool

I am working on multilingual site developed in asp.net MVC. Currently we are managing the translation task using resource (resx) file and everything is working fine.
Now as per client requirement, they want to integrate our resource file to a TMS "phrase" through a webhook. So in future, if they create any new key or modifying the existing resource file. Its automatically reflects in application resx file and it should automatically reflects on dev/test/prod environment.
As I tried to update the resource file on API call, its get modified and changes are reflected on application.
But when we modified the resx file under app_GlobalResources folder then it restarts the whole application. so this is one of drawback to use this approach. Also when we deploy our changes then it makes the dll of app_globalreources. Post deployment, unable to add new or make changes in existing translation.
Can any one suggest a best approach, which we should consider to fulfill above requirement.
Edit:-
Can we use json instead of resx file in existing application.
A common way to do translations is through database instead resource files. You save the same information in your database: language, key (the resource name) and value (the translated text).
With this focus, you must develop a way to do translations (the typical CRUD operations) and some layer to get any key in each language.
Talk with your client and check how important is this feature. I worked in a project like this some time ago and, at the end, we never do translations in this way. We add more functionality, made changes, translations and, when iteration finished, we move to production everything. Maybe not your case but it's a pity work on something that later hasn't use.

FTP with Swift 4/5 (with/without extra framework)

First of all: I know about the security concerns regarding ftp, so please no discussion about this here - ftp has to be used.
My app has to log into a server with ftp (with username/password), search for and download a file, delete it from the server, then upload an edited version.
I've been searching for tutorials on how to even get a connection to a server via ftp but all I found were Apple's documentation from 2012 here and their documentation about the different functions here (and a bunch of weird "Swift FTP" biking videos on youtube...). Every other example I found (usually <2015) uses some additional framework or library but there don't seem to be any proper tutorial for Swift 5 or even Swift 4.
Is it even still possible to use FTP with Swift 5 (is it still supported?) and if so, how? Or is there simply no point trying to get any of Apple's stuff to work and better to just use an extra framework like FileProvider?
At first I was using FileProvider, unfortunately the library is pretty buggy currently, with functions being called twice (which you can kind of prevent by using a "firstTimeCalled" bool check) and if the server's slow(-ish), you also might not get e.g. the full list of files in a directory because FileProvider stops receiving answers before the server's actually done.
I haven't found any other FTP libraries for Swift that work (and are still supported), so now I'm using BlueSocket (which is able to open sockets, send commands to the server and receive commands from it) and built my own small library that can send/receive,... files (using the FTP codes) around it.

How to use Google Drive in a Java Desktop app?

I am dealing with mobile and desktop applications. I am trying to use Google Drive as a permanent storage folder. Unfortunately I am at a loss because I cannot find any examples. Can someone point me at an example of storing or retrieving a file from Google Drive?
I would really like to see a simple example in code or maybe a library which can handle this. I am stuck at Retrieve and Use OAuth 2.0 Credentials https://developers.google.com/drive/credentials
Did you look at the sample app on the drive API page?
edit
google moved the examples to github
I don't know if I figured out your problem. What I have understood is that you are looking for a way that makes you able to work on the same project from different computers.
If so, you simply have to download Drive. Once install it will ask you what folder you want to keep syncronized with Drive. If you select your workspace, it will be syncronized with Drive. So, on another pc, if you have installed Drive, you will be able to use the workspace folder too, with the same files.
I hope this is helpful.
Marco
You should look into Documents List API.
The Google Drive API & SDK are meant to be a mean to integrate applications into the Web-UI of Google Drive. To protect the security of the user's files, it puts some restrictions to the application developer, like:
The app has to be installed from the Chrome Web Store
The app can only access files created from the app itself,
or files selected by the user using the Google Picker UI.
All these restrictions make the Google Drive API not a good choice for most non-web applications.
E.g. installing the app from the Chrome Web Store is probably something you would find cumbersome to request from your users for a mobile or desktop application. Nonetheless, without being installed from the Chrome Web Store your application will always receive an error when accessing a file from Google Drive.
The Documents List API allows you to store and load files (not only Google Documents!) into Google Drive.
This question is a little bit old, still. You can look at this example: https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2
They do the OAuth2 for accessing task. But I just used the same code to access the files using the v2 API. http://code.google.com/p/google-api-dotnet-client/wiki/APIs#Drive_API
I only retrieved the file list, but it is working (from .NET, desktop app).

Open a file that is on a file server from a webpage?

I am working on an internal application. We have a website that displays all our SSRS reports for a group of work. I have been asked to see if I can link all the files (pdf, word, excel) for the group of work. These files are stored on a file server that users viewing the reports have access to. Each group has its own group of reports and shared files.
Is it possible to open the files (without downloading them) from a webpage? Meaning that they file is opened from the file server? I don't want people to download a copy of the file.
I am pretty sure this can work with IE because sharepoint does it. However, other browsers may have an issue.
EDIT: What I would like is to have a web page with links to the files. When they click on a link (say for a word doc), word will open the file that resides on the file server. Without out a local copy downloaded from the network share.
EDIT2: Please note, I know what I am asking is probably not possible in all browsers. I am more or less just making sure. It seems possible in IE using activeX, but out side of that browsers do a good job at keeping processes inside a sandbox.
3 options. Remember this is for an internal website.
link to the share using file://. This will have the side affect of downloading the file to be viewed. As long as user clicks open every time it should not be a big deal.
Use JavaScript and activeX to open word (excel, reader, ect) passing in the file path as a command line arguments. This works only in IE and in win7 (probably vista) user will get a pop up asking if it is ok for the activeX control to run.
Create a new protocol. openfile://. This would be set up to run an application that is installed on the client machine which would open the file. Since it is internal, the application could be installed on the machines without issues. This also requires a registry change.
I haven't picked one as this change is still being looked into but i figure I would update this in case someone runs into something similar.

Resources