cloudinary 1.2.0 copy "cloudinary: ^1.2.0" to clipboard
cloudinary: ^1.2.0 copied to clipboard

A dart package to integrate Cloudinary API in Dart and Flutter.

cloudinary #

A dart package for to integrate Cloudinary API into your dart and flutter app. This package is a wrapper around the Cloudinary API.

pub package Stars Forks Watchers Contributors

GitHub release (latest by date) GitHub last commit GitHub issues GitHub pull requests GitHub Licence

Installation #

Add cloudinary as a dependency in your pubspec.yaml file:

dependencies:
  cloudinary: "latest_version"

Finally you just have to run: dart pub get or flutter pub get depending on the project type and this will download the dependency to your pub-cache.

And import it:

import 'package:cloudinary/cloudinary.dart';

Usage #

Initialize a Cloudinary object #

/// This three params can be obtained directly from your Cloudinary account Dashboard.
/// The .signedConfig(...) factory constructor is recommended only for server side apps, where [apiKey] and 
/// [apiSecret] are secure. 
final cloudinary = Cloudinary.signedConfig(
  apiKey: apiKey,
  apiSecret: apiSecret,
  cloudName: cloudName,
);

or

/// The .unsignedConfig(...) factory constructor is recommended for client side apps, where [apiKey] and 
/// [apiSecret] must not be used, so .basic(...) constructor allows to do later unsigned requests.
final cloudinary = Cloudinary.unsignedConfig(
  cloudName: cloudName,
);

Do a signed file upload #

Recommended only for server side apps.


final response = await
cloudinary.upload
(
file: file.path,
fileBytes: file.readAsBytesSync(),
resourceType: CloudinaryResourceType.image,
folder: cloudinaryCustomFolder,
fileName: 'some-name',
progressCallback: (count, total) {
print(
'Uploading image from file with progress: $count/$total');
}),
);

if(response.isSuccessful) {
print('Get your image from with ${response.secureUrl}');
}   

You can upload a file from path or byte array representation, you can also pass an optParams map to do a more elaborated upload according to https://cloudinary.com/documentation/image_upload_api_reference The cloudinary.upload(...) function is fully documented, you can check the description to know what other options you have.

Do a unsigned file upload #

Recommended for server client side apps. The way to do this request is almost the same as above, the only difference is the uploadPreset which is required for unsigned uploads.


final response = await
cloudinary.unsignedUpload
(
file: file.path,
uploadPreset: somePreset,
fileBytes: file.readAsBytesSync(),
resourceType: CloudinaryResourceType.image,
folder: cloudinaryCustomFolder,
fileName: 'some-name',
progressCallback: (count, total) {
print(
'Uploading image from file with progress: $count/$total');
})
);

if(response.isSuccessful) {
print('Get your image from with ${response.secureUrl}');
}

You can upload a file from path or byte array representation, you can also pass an optParams map to do a more elaborated upload according to https://cloudinary.com/documentation/image_upload_api_reference The cloudinary.unsignedUpload(...) function is fully documented, you can check the description to know what other options you have.

Do a file delete (this will use the cloudinary destroy method) #


final response = await
cloudinary.destroy
('public_id
'
,url: url,
resourceType: CloudinaryResourceType.image,
invalidate: false,
);
if(response.isSuccessful ?? false){
//Do something else
}

To delete a cloudinary file it´s necessary a public_id, as you can see in the sample code the deleteResource(...) function can delete a file by it's url... You can also pass an optParams map to do a more elaborated delete (destroy) according to https://cloudinary.com/documentation/image_upload_api_reference#destroy_method The cloudinary.destroy(...) function is fully documented, you can check the description to know what other options you have.

About Cloudinary #

Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently manage, transform, optimize, and deliver images and videos through multiple CDNs. Ultimately, viewers enjoy responsive and personalized visual-media experiences—irrespective of the viewing device.

Get Help #

If you run into an issue or have a question, you can either:

Connect With Me #

Instagram: nixrajput Linkedin: nixrajput GitHub: nixrajput Twitter: nixrajput07 Facebook: nixrajput07

24
likes
160
points
1.2k
downloads

Publisher

verified publishernixrajput.com

Weekly Downloads

A dart package to integrate Cloudinary API in Dart and Flutter.

Homepage
Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

crypto, dio

More

Packages that depend on cloudinary