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.
Related
I'm trying to create a webview with the capability to block/redirect certain urls requested inside the webview (not just the page url, but also the requests sent from the page, think of it as what a browser extension is able to do).
After some research, the closest I get was this Swift/Obj-c approach of use NSUrlProtocol: https://www.raywenderlich.com/2292-using-nsurlprotocol-with-swift, and the doc of the native-webview-ext mentioned something about WKURLSchemeHandler https://github.com/Notalib/nativescript-webview-ext .
I'm new to mobile development and this feature is crucial for my project. I wonder if anyone has experience building this out in NativeScript, I hope I don't have to convince my team and my boss to write this in Swift instead :(.
As you see in the webview-ext plugin docs, it does support overriding resource urls. Refer the registerLocalResource method.
Just in case, even if that is not supported you don't have to write your whole project in Swift as you can always access all native apis from JavaScript / TypeScript itself, read more about it here.
I am developing a WebExtension for Firefox. In order to post my extension, it must not have any remote scripts in it.
In order to display some tweets in my extension's menu, I have used the Twitter-Post-Fetcher library, but I can't post my extension with it because the library uses remote scripts from twitter.com.
I prefer not to use the Twitter API if possible, because the requests would come from the extension's users.
No remote scripts means that if you are going execute code in the context of your extension, then the code must be included in the extension package, not hosted on some server. While there may be other ways to accomplish this (e.g. running the code in the page context, which may be acceptable, but may not), the default way to accomplish this is to: download the code that you are executing and use a copy that you include in the extension package.
This is the case for all code, including libraries such as jQuery. It is highly recommended that the code be an exact byte-by-byte copy of code that can be downloaded from a public repository, and that you indicate within your extension package the exact URL you used to obtain the code.
The reason for this is security. If downloading code at runtime was permitted, then that code could be trivially changed at any time. It would mean that having the add-on reviewed by Mozilla would be of no benefit.
Please see the Review Policies page on MDN, and all the pages linked from there, for more details.
I am working on an App, in which I want to upload images and pdf to the FTP server. I am using this reference ref.All is working good. The images and pdf are getting uploaded on the server with proper names and sizes.
But, now I want to check if the directory is already exists on the server or not. I am not able to get it to work with this library.
So my question is that how to check directory on ftp,if directory is there then upload the files if not then first create directory on ftp and then upload files onto that directory?
Any Ideas.. ? Any help will be appreciated.
Different FTP servers will answer the LIST request in differing ways, so there is no single answer to this question. RFC959 says on the matter:
Since the information on a file may vary widely from system
to system, this information may be hard to use automatically
in a program, but may be quite useful to a human user.
Using the CWD request to change into the directory in question, and detecting a successful response will detect the directory, however that leaves you in that directory as a potentially unrequired side effect.
For these reasons, as well as others, you may find more modern protocols such as SSH (which includes a file transfer feature) to be more useful. You may find the DLSFTPClient CocoaPod useful.
M.
I have a website, let's say it's "http://www.jwilkthings.com/stuff"
I have a bunch of .txt files stored on this website, i.e. "http://www.jwilkthings.com/stuff/text1.txt"
What I'm wanting to do is find a way in iOS to download all of those text files without knowing what the document name is. I can already retrieve them manually as long as I have a file name, but I would rather just get all of them at once and put them in the documents directory if possible. I currently use FileZilla to upload all of the text files, so I can use FTP if needed.
The correct way to solve this problem is to not use FTP (riddled with performance and security issues), and to configure your web server to expose a table of contents directory listing that your client can parse.
But that's not an answer to your question.
If you really want your iOS app to speak FTP, take a look at the SimpleFTP sample project from Apple.
It's old, but I just got it to build on iOS 5. The ListController.m file has the code you're looking for.
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.