S3 Bucket File Uploader š
A brick to get the s3 bucket file uploading service.
Generated by [mason][1] š§±
Dependencies
This brick is dependent on the following dependencies. You have to add them in your pubspec.ymal under dependencies:
mime: ^1.0.4
sn_progress_dialog: ^1.1.3
get_it: ^7.6.4
Setup
Add the following lines to your main.dart file.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// add this line
registerGlobalServieces();
runApp(const BaseWidget(Routes.SPLASH));
}
// add this method
void registerGlobalServieces() {
GetIt.instance.registerSingleton<FileUploadRepository>(
FileUploadRepository(
imageUploadService: FileUploadService(
backendUrlforS3Credentials: getS3SignedUrlsApiConstant,
xAccessToken: Configuration().xAccessToken,
),
),
);
}
Usage
FileUploadRepository fileUploadRepository =
GetIt.instance.get<FileUploadRepository>();
final RepositoryResponse<String> s3ResponseUrls =
await fileUploadRepository.getSignedUrlsFromBackend(
filePath: *** your file path ***,
);
if (s3ResponseUrls.isSuccess){
// s3 bucket uploaded file path
print(s3ResponseUrls.data!);
}