sabowsla_storage 0.0.1 copy "sabowsla_storage: ^0.0.1" to clipboard
sabowsla_storage: ^0.0.1 copied to clipboard

Dart client library to interact with Sabowsla Storage. Sabowsla Storage provides an interface for managing Files stored in Sabowsla Server, using ISAR database as your database.

example/main.dart

// ignore_for_file: avoid_print

import 'dart:io';
import 'dart:typed_data';

import 'package:sabowsla_storage/sabowsla_storage.dart';

Future<void> main() async {
  const sabowslaUrl = '';
  const sabowslaKey = '';
  final client = SabowslaStorageClient(
    '$sabowslaUrl/storage/v1',
    {
      'Authorization': 'Bearer $sabowslaKey',
    },
  );

  // Upload binary file
  final List<int> listBytes = 'Hello world'.codeUnits;
  final Uint8List fileData = Uint8List.fromList(listBytes);
  final uploadBinaryResponse = await client.from('public').uploadBinary(
        'binaryExample.txt',
        fileData,
        fileOptions: const FileOptions(upsert: true),
      );
  print('upload binary response : $uploadBinaryResponse');

  // Upload file to bucket "public"
  final file = File('example.txt');
  file.writeAsStringSync('File content');
  final storageResponse =
      await client.from('public').upload('example.txt', file);
  print('upload response : $storageResponse');

  // Get download url
  final urlResponse =
      await client.from('public').createSignedUrl('example.txt', 60);
  print('download url : $urlResponse');

  // Download text file
  try {
    final fileResponse = await client.from('public').download('example.txt');
    print('downloaded file : ${String.fromCharCodes(fileResponse)}');
  } catch (error) {
    print('Error while downloading file : $error');
  }

  // Delete file
  final deleteResponse = await client.from('public').remove(['example.txt']);
  print('deleted file id : ${deleteResponse.first.id}');

  // Local file cleanup
  if (file.existsSync()) file.deleteSync();
}
0
likes
130
points
9
downloads

Publisher

unverified uploader

Weekly Downloads

Dart client library to interact with Sabowsla Storage. Sabowsla Storage provides an interface for managing Files stored in Sabowsla Server, using ISAR database as your database.

Homepage
Repository (GitHub)

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

http, http_parser, meta, mime, retry

More

Packages that depend on sabowsla_storage