media_link_generator 0.0.3 copy "media_link_generator: ^0.0.3" to clipboard
media_link_generator: ^0.0.3 copied to clipboard

Can upload any type of files and get generated link by Media link storage. its totaly free to use free storage

example/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:media_link_generator/media_link_generator.dart';

void main() {
  runApp(MaterialApp(home: HomePage()));
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Upload Media Files")),
      body: Column(
        children: [
          /////////// 1. Generate Token
          //// can set from main function one time only
          ElevatedButton(
            onPressed: () async {
              // get token directly
              var result = await MediaLink().generateTokenByEmail(
                "yourEmail@gmail.com",
                shouldPrint: true,
              );
              debugPrint(result.toString()); // 37160f2e00721d906831565829ae1de7

              //// set token
              MediaLink().setToken(result!); // if  can get from user dashboard from website
              // token like: 37160f2e00721d906831565829ae1de7
            },
            child: Text("Generate And Set Token One Time Only"),
          ),

          /////// 2 . Generate Link
          Text("Upload Media Files For Generate Link"),
          ElevatedButton(
            onPressed: () async {
              var getLink = await MediaLink().uploadFile(
                File("filePath"),
                folderName: "items",
                isSecret:
                    false, // fully secured file only can see by generated link and file can not be opend without this generate link
                fromDeviceName: "iphone 16 pro",
                shouldPrint: true,
                onUploadProgress: (uploadingPercentage) {
                  debugPrint(uploadingPercentage.toString());
                },
              );

              debugPrint(getLink.toJson().toString());
            },
            child: Text("Upload File with encyption"),
          ),

          /////////// 3. Delete Token
          ElevatedButton(
            onPressed: () async {
              var result = await MediaLink().deleteFile(
                "fileLink",
                shouldPrint: true,
              );
              if (result) {
                debugPrint("Deleted");
              } else {
                debugPrint("Not Deleted");
              }
            },
            child: Text("Delete File"),
          ),
        ],
      ),
    );
  }
}
1
likes
0
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

Can upload any type of files and get generated link by Media link storage. its totaly free to use free storage

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

dio, flutter

More

Packages that depend on media_link_generator