Giter Site home page Giter Site logo

dospace's Introduction

DOSpace

Client library to interact with the DigitalOcean Spaces API.

Usage

A simple usage example:

import 'dart:async';
import 'package:dospace/dospace.dart' as dospace;

main() async {
  dospace.Spaces spaces = new dospace.Spaces(
    region: "nyc3",
    accessKey: "7Q7GAFJ4IXHQVLBRXSRX",
    secretKey: "2JLXa9RqPwpavBkC7dt1MHWUDfd6onaXTXTfSYc5eQ0",
  );
  for (String name in await spaces.listAllBuckets()) {
    print('bucket: ${name}');
    dospace.Bucket bucket = spaces.bucket(name);
    await for (dospace.BucketContent content in bucket.listContents(maxKeys: 3)) {
       print('key: ${content.key}');
    }
  }
  String etag = await spaces.bucket('example').uploadFile(
    'README.md', 'README.md', 'text/plain', dospace.Permissions.public);
  print('upload: $etag');
  await spaces.close();
}

References

dospace's People

Contributors

iamdipanshusingh avatar kaetemi avatar komangnopha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dospace's Issues

This library is not working in Flutter web

I am trying to upload File instance from 'dart:html' but this library is not able to upload the files. I have tried multiple things, like converted file instance to Uint8List also

Setting Cache-control metadata to bucket.uploadFile gets overwritten /updated as custom metadata

Setting Cache-control metadata to bucket.uploadFile gets overwritten /updated as custom metadata.

e.g. Map<String, String> metadata = {'Cache-Control':'public'}
String etag = await bucket.uploadFile(
objectKey, File(filePath), lookupMimeType(filePath), dospace.Permissions.public,meta: metadata);

uploads with the metadata as x-amz-meta-cache-control. dospace_bucket.dart overrides the metadata value always with x-amz

outdated xml dependency issue

Hi,

Your xml dependency is very outdated and is clashing with other packages. Plz consider upgrading it. Have also raised a PR for the same.

Thanks

Xml dependency issue

Hello,

can you update the xml dependency? Because it causes problems with other libraries that use a high version of xml.

Thanks

Simplify library usage

Instead of making separate client objects for the spaces server and buckets, have a separate Spaces client and Bucket client. The Spaces client should have a function to create the Bucket client, and adjust the endpoint Uri accordingly. It should still be possible for the user to create the Bucket client directly.

Delegated upload from client app

The client app will send to the server the filetype, filesize, and sha256 hash of the file which it needs to upload. In general these files will be images. It may be nice to let the library generate the options, if it proves useful and practical.

After validating the received options, the server will generate the key for the file in the storage bucket, store this key with the user's account in the database, and then use the library to generate the signed HTTP request to upload the data. The request headers and options are then sent to the client app.

Using the pre-signed HTTP request from the server, the client will upload the file, and notify the server when it is finished. The library is used to handle the upload properly with the pre-signed request.

Handling failed or non-uploaded files and other database cleanup is up to the server, and not a concern here.

Upload and download routines

  • String downloadText()
    • This would verify if content-type starts with text/
  • downloadImage()
    • This would verify if content-type starts with image/
  • downloadFile()
  • uploadText(String text)
  • (uploadImage?)
  • uploadFile

Library should handle everything behind the scenes.

We also want a mechanism for pre-signing both uploads and downloads in the style of new Bucket.signed(string endpointUrl, string key, Map<String, String> signatureHeaders) as specified by issue #1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.