minio-dart icon indicating copy to clipboard operation
minio-dart copied to clipboard

fPutObject is not defined?

Open FickleLife opened this issue 4 years ago • 5 comments

The below gives me a The method 'fPutObject' isn't defined for the type 'Minio'. error - any idea where I am going wrong? minio: ^1.3.0

import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:injectable/injectable.dart';
import 'package:minio/minio.dart';

@lazySingleton
class MinioService {
  final minio = Minio(
    endPoint: DotEnv().env['MINIO_ENDPOINT_DEV'],
    accessKey: DotEnv().env['MINIO_ACCESS_KEY_DEV'],
    secretKey: DotEnv().env['MINIO_SECRET_KEY_DEV'],
    useSSL: true,
  );

  final bucket = '00test';
  final object = 'custed.png';
  final copy1 = 'custed.copy1.png';
  final copy2 = 'custed.copy2.png';

  Future<String> uploadProductPhoto(photo) async {
    final String etag = await minio.fPutObject(bucket, object, 'photos_product_upload/$object');
    print('--- etag:');
    print(etag);
    return etag;
  }
}

FickleLife avatar Jan 13 '21 01:01 FickleLife

I can reproduce this problem.

The function fPutObject() is defined in the extension MinioX for the class Minio. The latter class is defined in the file src/minio.dart which is exported from this library, but the extension MinioX inside the file io.dart isn't exported.

I assume that this is not the intended behaviour because fPutObject() is advertised in the README of this library and offers different functionality than putObject(), @xtyxtyx ?

philenius avatar Jan 14 '21 22:01 philenius

Bug fix: add export 'io.dart'; in minio.dart.

philenius avatar Jan 14 '21 22:01 philenius

I've created a pull request. See PR #19.

philenius avatar Jan 14 '21 22:01 philenius

Simply import 'package:minio/io.dart'; to enable fPutObject.

I've added an example here.

xtyxtyx avatar Jan 15 '21 01:01 xtyxtyx

Because fPutObject() and fGetObject() depend on dart:io, including these two functions directly in src/minio.dart will make this package not working on web.

Similar techniques are used in packages such as shelf.

xtyxtyx avatar Jan 15 '21 01:01 xtyxtyx