flutter_publitio 1.0.5 flutter_publitio: ^1.0.5 copied to clipboard
Publit.io plugin for Flutter, allowing uploading, hosting and delivering media assets images and videos.
Publit.io plugin for Flutter #
A Flutter plugin that wraps the native Publit.io API SDKs, for hosting and managing media assets (videos and images).
Security warning #
This method stores your publitio API key and secret on the client. This has security implications. Unless you're OK with all your files being theoretically available to all clients to view and modify, you should either call publitio from the server side (without this plugin), or use a method that supports serverless auth like I describe here
Getting started #
See the example
directory for a complete sample app showing video upload and playback. Works on iOS and Android.
For a more advance example, check out https://github.com/syonip/flutter_video_sharing
To run the example app you'll need credentials:
- Create a free account at Publit.io, and get your credentials from the dashboard.
- Put your API key and secret in
example/ios/Runner/Info.plist
, and inexample/lib/main.dart
(replace the text"YOUR_API_KEY"
and"YOUR_API_SECRET"
respectively) - Run the example by typing
flutter run
from theexample
directory.
Usage #
Add flutter_publitio
as a dependency in your pubspec.yaml
.
Configure #
await FlutterPublitio.configure("YOUR_API_KEY", "YOUR_API_SECRET");
Upload #
final uploadOptions = {
"privacy": "1", // Marks file as publicly accessible
"option_download": "1", // Can be downloaded by anyone
"option_transform": "1" // Url transforms enabled
};
final response = await FlutterPublitio.uploadFile("file path", uploadOptions);
print(response["url_preview"]);
Features #
This plugin currently supports the uploadFile
function. If you need more functions, please let me know by opening an issue (or make a PR 😜)