SDKs overview

Filestack provides a range of Software Development Kits (SDKs) and libraries designed to facilitate the integration of its file handling capabilities into various applications and platforms. These SDKs abstract the underlying RESTful API, offering language-specific methods and components for tasks such as file uploading, content transformation, and secure delivery. The SDKs are available for popular web frameworks, mobile platforms, and backend programming languages, enabling developers to incorporate Filestack's features without extensive low-level API interaction. The official SDKs are regularly maintained and updated to align with the latest Filestack API features and best practices for file management.

The core functionality supported by the SDKs includes:

  • File Uploader: Components and functions to allow users to select and upload files from local devices, cloud storage providers (e.g., Google Drive, Dropbox), or social media platforms (Filestack file upload documentation).
  • Image and Video Transformations: Methods to apply real-time manipulations to media files, such as resizing, cropping, watermarking, and format conversions (Filestack transformations guide).
  • Content Ingestion and Storage: Tools for managing where uploaded files are stored, including options for custom storage locations.
  • Content Delivery Network (CDN) Integration: Built-in support for optimized content delivery, ensuring fast access to files globally.

These SDKs are designed to enhance the developer experience by providing ready-to-use components and simplifying complex file operations, making it easier to handle user-generated content and media assets across different application environments.

Official SDKs by language

Filestack offers official SDKs for a variety of programming languages and frameworks, ensuring broad compatibility for different development stacks. These SDKs are maintained by Filestack and are the recommended way to interact with the Filestack API. Each SDK provides idiomatic interfaces for its respective language, simplifying integration and reducing development time. The table below outlines the key official SDKs, their typical package names, and installation commands.

Language/Framework Package/Module Name Installation Command Maturity
JavaScript (Browser) filestack-js npm install filestack-js or yarn add filestack-js Stable
React react-filestack npm install react-filestack or yarn add react-filestack Stable
Angular @filestack/angular npm install @filestack/angular or yarn add @filestack/angular Stable
iOS (Swift/Objective-C) FilestackSDK Via CocoaPods (pod 'FilestackSDK') or Carthage Stable
Android (Java/Kotlin) filestack-android Via Gradle (implementation 'com.filestack:filestack-android:x.y.z') Stable
Python filestack-python pip install filestack-python Stable
Ruby filestack-ruby Add gem 'filestack-ruby' to Gemfile and run bundle install Stable
PHP filestack/filestack-php composer require filestack/filestack-php Stable
Java filestack-java Via Maven or Gradle Stable
.NET Filestack.NET Install-Package Filestack.NET (NuGet) Stable

Each SDK is designed to provide comprehensive access to Filestack's features, from uploading and transforming files to managing their delivery. Developers can find detailed API references and usage examples for each SDK in the official Filestack documentation.

Installation

Installing Filestack SDKs typically follows the standard package management practices for each respective language or platform. Below are general guidelines and specific examples for popular SDKs.

JavaScript (Web)

For web-based applications, the filestack-js library is installed via npm or yarn:

npm install filestack-js
# or
yarn add filestack-js

After installation, you can import and initialize the client in your JavaScript code:

import * as filestack from 'filestack-js';

const client = filestack.init('YOUR_API_KEY');

React

For React applications, use the dedicated react-filestack library:

npm install react-filestack
# or
yarn add react-filestack

This library provides React components that wrap the core Filestack functionality.

Python

The Python SDK, filestack-python, is installed using pip:

pip install filestack-python

Once installed, you can use it in your Python scripts:

from filestack import Client

client = Client('YOUR_API_KEY')

iOS (Swift)

For iOS development, Filestack recommends using CocoaPods for dependency management:

# In your Podfile
pod 'FilestackSDK'

# Then run
pod install

After installation, import the module in your Swift files:

import FilestackSDK

Android (Java/Kotlin)

For Android projects, add the Filestack SDK to your build.gradle file:

dependencies {
    implementation 'com.filestack:filestack-android:+'
}

Then synchronize your project with Gradle files. More detailed instructions for each SDK are available in the Filestack SDKs documentation.

Quickstart example

This quickstart example demonstrates how to implement a basic file uploader using the filestack-js SDK in a web application. This example allows users to select a file and upload it to Filestack storage.

HTML Structure

First, create an HTML file with a button to trigger the uploader and a place to display the uploaded file's URL:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Filestack Quickstart</title>
</head>
<body>
    <h1>Upload a File</h1>
    <button id="uploadButton">Select and Upload File</button>
    <p>Uploaded File URL: <a id="fileUrl" href="#" target="_blank"></a></p>

    <script src="https://static.filestackapi.com/filestack-js/3.x.x/filestack.min.js"></script>
    <script src="app.js"></script>
</body>
</html>

JavaScript (app.js)

Next, create an app.js file. Replace 'YOUR_API_KEY' with your actual Filestack API key. This script initializes the Filestack client and configures the picker to handle file uploads.

// Initialize Filestack client with your API key
const client = filestack.init('YOUR_API_KEY');

// Get references to HTML elements
const uploadButton = document.getElementById('uploadButton');
const fileUrlAnchor = document.getElementById('fileUrl');

// Add event listener to the upload button
uploadButton.addEventListener('click', () => {
    // Open the Filestack picker
    client.picker({
        onFileUploadFinished: (file) => {
            // Callback when a file upload is completed
            console.log(file);
            // Display the URL of the uploaded file
            fileUrlAnchor.href = file.url;
            fileUrlAnchor.textContent = file.url;
            alert('File uploaded successfully! URL: ' + file.url);
        },
        onFileUploadProgress: (progress) => {
            // Optional: Log upload progress
            console.log('Upload progress:', progress);
        },
        onOpen: () => {
            console.log('Filestack picker opened');
        },
        onClose: () => {
            console.log('Filestack picker closed');
        },
        onError: (error) => {
            // Handle any errors during upload
            console.error('Filestack upload error:', error);
            alert('File upload failed: ' + error.message);
        }
    }).open();
});

This example demonstrates how to set up the Filestack uploader, handle successful uploads, and display the resulting file URL. The picker offers extensive configuration options for sources, transformations, and storage settings, as detailed in the Filestack Picker documentation.

Community libraries

While Filestack provides a comprehensive set of official SDKs, the developer community also contributes libraries and integrations that extend its functionality or adapt it to specific niche use cases or frameworks. These community-driven projects can offer alternative approaches, specialized components, or support for languages not officially covered by Filestack. For instance, developers might create wrapper libraries for less common front-end frameworks, integrate Filestack with specific content management systems, or build tools for advanced automation of file workflows.

Community libraries are typically found on platforms like GitHub, npm, or Packagist. When evaluating a community library, it is advisable to consider its maintenance status, community activity, and compatibility with the latest Filestack API versions. Examining the project's documentation, issue tracker, and recent commits can provide insights into its reliability and ongoing support. For example, a community might develop a specialized uploader for a niche JavaScript framework or a server-side utility for bulk operations not directly covered by the official SDKs.

As with any third-party dependency, developers should review the source code and licensing of community libraries before incorporating them into production environments. Information about community contributions can sometimes be found in the Filestack documentation or through general developer community channels and forums, such as Stack Overflow, which serves as a common resource for API usage questions and community-shared solutions (Filestack questions on Stack Overflow).