Skip to content

ObscureMosquito/Skyglow-File-Picker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Skyglow File Picker


Skyglow File Picker is a static UIKit library that functions like `UIDocumentPicker` now does, but pre iOS 8 devices. It gives you a browseable file picker and includes a lightweight HTTP upload view so users can import files from another device on the same network.

What It Includes

  • A UITableViewController-based file picker rooted at /var/mobile by default
  • Filename, extension, and full-path filtering
  • Hidden-file toggling
  • Symlink-aware browsing and selection
  • A small embedded HTTP upload server UI for importing files into the current directory

Installing

The releases ZIP produced by the build script contains:

  • lib/SFPFilePicker.a
  • include/SFPFilePicker.h

Add the root extracted folder to your project, copy the header into your include path, or reference it manually from where you use the API, and link against UIKit and CoreGraphics.

Developer Guide

Public API

Normal integrations only need one header:

  • SFPFilePicker/SFPFilePicker.h

The upload view controller and HTTP server headers stay in the source tree as implementation details, but the release package is meant to be consumed through the main picker API.

Basic Usage

Create a picker, wrap it in a UINavigationController, and present it modally.

#import <SFPFilePicker/SFPFilePicker.h>

@interface MyController : UIViewController <SFPFilePickerDelegate>
@end

@implementation MyController

- (void)showPicker {
    SFPFilePickerFilter *filter = [[[SFPFilePickerFilter alloc] init] autorelease];
    filter.allowedExtensions = [NSArray arrayWithObjects:@"plist", @"txt", nil];

    SFPFilePickerViewController *picker =
        [SFPFilePickerViewController pickerWithFilter:filter delegate:self];
    picker.showsHiddenFiles = NO;
    picker.showsCancelButton = YES;

    UINavigationController *navigationController =
        [[[UINavigationController alloc] initWithRootViewController:picker] autorelease];

    [self presentModalViewController:navigationController animated:YES];
}

- (void)filePicker:(SFPFilePickerViewController *)picker
didSelectFileAtPath:(NSString *)path {
    NSLog(@"Selected file: %@", path);
    [self dismissModalViewControllerAnimated:YES];
}

- (void)filePickerDidCancel:(SFPFilePickerViewController *)picker {
    [self dismissModalViewControllerAnimated:YES];
}

@end

Picker Configuration

SFPFilePickerFilter supports three optional match lists:

  • allowedExtensions Use extensions without a leading dot, such as @"deb" or @"plist".
  • allowedFilenames Use exact filenames such as @"Info.plist".
  • allowedPaths Use absolute paths when you want to explicitly allow only specific files.

If every filter array is nil or empty, the picker allows all regular files.

Directories and symlinks to directories stay browseable so the user can keep navigating, but only regular files and symlinks to files are returned through the delegate.

Starting From a Custom Directory

Use the designated initializer when you do not want to start at /var/mobile.

SFPFilePickerViewController *picker =
    [[[SFPFilePickerViewController alloc] initWithPath:@"/var/root"
                                                filter:nil
                                              delegate:self] autorelease];

Refreshing and Hidden Files

The picker exposes:

  • showsHiddenFiles Set this before presentation or toggle it later.
  • showsCancelButton Controls whether the picker shows a cancel control.
  • allowsHTTPUpload Enables or hides the built-in HTTP upload action.
  • httpUploadStartPort Sets the first port the built-in upload server should try. The default is 8080.
  • reloadDirectory Forces the current directory to be re-read from disk.

On iPhoneOS 2, where UINavigationController toolbars are not available, the picker automatically falls back to a navigation-bar action sheet so refresh, hidden-file toggling, and HTTP upload still remain accessible.

HTTP Upload UI

The picker includes an upload action that presents the built-in HTTP importer for the current directory. It shows the local upload URL and updates a progress bar as the incoming file is received.

You can configure that behavior entirely from SFPFilePickerViewController:

picker.allowsHTTPUpload = YES;
picker.httpUploadStartPort = 8080;

If you do not want the importer exposed in your integration, set allowsHTTPUpload to NO.

Build Instructions

The project ships with a build script:

./build.sh

The script runs these builds:

  • armv6 with TARGET="iphone:clang:5.1:2.0"
  • armv7 armv7s with TARGET="iphone:clang:6.0:3.0"
  • arm64 with TARGET="iphone:clang:7.0:7.0"

That means your Theos setup needs these SDKs installed:

  • iPhoneOS5.1.sdk
  • iPhoneOS6.0.sdk
  • iPhoneOS7.0.sdk

After building, the script:

  • creates SFPFilePicker.a
  • copies the public headers into a release layout
  • produces SFPFilePicker-Release.zip

Notes

  • The library is built AND meant to work without Automatic Reference Counting.
  • The HTTP uploader is intentionally small and aimed at local import convenience, not large-file transfer or internet exposure, and is not exhaustively tested against common attacks or vulnerabilities (why would you expose this to the interntet anyways?).

Examples:

About

The missing UIDocumentPicker for devices iPhoneOS 2 to iOS 7, a simple file picker with an HTTP import utility.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages