You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-7Lines changed: 34 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,37 @@
1
1
# cloudinary
2
2
3
-
A dart package to integrate Cloudinary API in Dart and Flutter.
3
+
A dart package for to integrate [Cloudinary](https://cloudinary.com/) API into your dart and flutter app. This package is a wrapper around the [Cloudinary API](https://cloudinary.com/documentation/image_upload_api_reference).
The first thing is to add **cloudinary** as a dependency of your project, for this you can use the command:
10
13
11
-
**For purely Dart projects**
14
+
Add **cloudinary** as a dependency of your project, for this you can use the command:
15
+
16
+
**For Dart projects**
17
+
12
18
```shell
13
19
dart pub add cloudinary
14
20
```
21
+
15
22
**For Flutter projects**
23
+
16
24
```shell
17
25
flutter pub add cloudinary
18
26
```
19
-
This command will add **cloudinary_sdk** to the **pubspec.yaml** of your project.
20
-
Finally you just have to run:
21
27
22
-
`dart pub get`**or**`flutter pub get` depending on the project type and this will download the dependency to your pub-cache
28
+
This command will add **cloudinary** to the **pubspec.yaml** of your project.
29
+
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
23
30
24
31
## Usage
32
+
25
33
### Initialize a Cloudinary object
34
+
26
35
```dart
27
36
/// This three params can be obtained directly from your Cloudinary account Dashboard.
28
37
/// The .signedConfig(...) factory constructor is recommended only for server side apps, where [apiKey] and
@@ -33,7 +42,9 @@ final cloudinary = Cloudinary.signedConfig(
33
42
cloudName: cloudName,
34
43
);
35
44
```
45
+
36
46
or
47
+
37
48
```dart
38
49
/// The .unsignedConfig(...) factory constructor is recommended for client side apps, where [apiKey] and
39
50
/// [apiSecret] must not be used, so .basic(...) constructor allows to do later unsigned requests.
@@ -43,7 +54,9 @@ final cloudinary = Cloudinary.unsignedConfig(
43
54
```
44
55
45
56
### Do a signed file upload
57
+
46
58
Recommended only for server side apps.
59
+
47
60
```dart
48
61
final response = await cloudinary.upload(
49
62
file: file.path,
@@ -62,12 +75,15 @@ Recommended only for server side apps.
62
75
}
63
76
64
77
```
78
+
65
79
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
66
80
The `cloudinary.upload(...)` function is fully documented, you can check the description to know what other options you have.
67
81
68
82
### Do a unsigned file upload
83
+
69
84
Recommended for server client side apps.
70
85
The way to do this request is almost the same as above, the only difference is the `uploadPreset` which is required for unsigned uploads.
86
+
71
87
```dart
72
88
final response = await cloudinary.unsignedUpload(
73
89
file: file.path,
@@ -87,10 +103,12 @@ The way to do this request is almost the same as above, the only difference is t
87
103
}
88
104
89
105
```
106
+
90
107
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
91
108
The `cloudinary.unsignedUpload(...)` function is fully documented, you can check the description to know what other options you have.
92
109
93
110
### Do a file delete *(this will use the cloudinary destroy method)*
111
+
94
112
```dart
95
113
final response = await cloudinary.destroy('public_id',
96
114
url: url,
@@ -101,10 +119,19 @@ The `cloudinary.unsignedUpload(...)` function is fully documented, you can check
101
119
//Do something else
102
120
}
103
121
```
122
+
104
123
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...
105
124
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
106
125
The `cloudinary.destroy(...)` function is fully documented, you can check the description to know what other options you have.
107
126
127
+
## About Cloudinary
128
+
129
+
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.
130
+
131
+
## Get Help
132
+
If you run into an issue or have a question, you can either:
133
+
- Issues related to the SDK: [Open a Github issue](https://github.com/nixrajput/cloudinary-dart/issues).
@@ -138,7 +158,8 @@ class CloudinaryApiClient extends CloudinaryApi {
138
158
'public_id': publicId ?? fileName,
139
159
if (folder !=null) 'folder': folder,
140
160
141
-
/// Setting the optParams... this would override the public_id and folder if specified by user.
161
+
/// Setting the optParams... this would override the public_id and folder
162
+
/// if specified by user.
142
163
if (optParams?.isNotEmpty ??false) ...optParams!,
143
164
};
144
165
@@ -173,10 +194,14 @@ class CloudinaryApiClient extends CloudinaryApi {
173
194
/// Deletes a file of [resourceType] with [publicId]
174
195
/// from your specified [cloudName]
175
196
///
176
-
/// [publicId] The identifier of the uploaded asset. Note: The public ID value for images and videos should not include a file extension. Include the file extension for raw files only.
197
+
/// [publicId] The identifier of the uploaded asset. Note: The public ID value
198
+
/// for images and videos should not include a file extension. Include the
199
+
/// file extension for raw files only.
177
200
/// [resourceType] defaults to [CloudinaryResourceType.image]
178
-
/// [invalidate] If true, invalidates CDN cached copies of the asset (and all its transformed versions). Default: false.
179
-
/// [optParams] a Map of optional parameters as defined in https://cloudinary.com/documentation/image_upload_api_reference#destroy_method
201
+
/// [invalidate] If true, invalidates CDN cached copies of the asset (and all
202
+
/// its transformed versions). Default: false.
203
+
/// [optParams] a Map of optional parameters as defined in
/// [publicId] the asset id in your [cloudName], if not provided then [url] would be used. Note: The public ID value for images and videos should not include a file extension. Include the file extension for raw files only.
123
-
/// [url] the url to the asset in your [cloudName], the publicId will be taken from here
124
-
/// [cloudinaryImage] a Cloudinary Image to be deleted, the publicId will be taken from here
120
+
/// [publicId] the asset id in your [cloudName], if not provided then [url]
121
+
/// would be used. Note: The public ID value for images and videos should not
122
+
/// include a file extension. Include the file extension for raw files only.
123
+
/// [url] the url to the asset in your [cloudName], the publicId will be taken
124
+
/// from here
125
+
/// [cloudinaryImage] a Cloudinary Image to be deleted, the publicId will
126
+
/// be taken from here
125
127
/// [resourceType] defaults to [CloudinaryResourceType.image]
126
-
/// [invalidate] If true, invalidates CDN cached copies of the asset (and all its transformed versions). Default: false.
127
-
/// [optParams] a Map of optional parameters as defined in https://cloudinary.com/documentation/image_upload_api_reference#destroy_method
128
+
/// [invalidate] If true, invalidates CDN cached copies of the asset (and all
129
+
/// its transformed versions). Default: false.
130
+
/// [optParams] a Map of optional parameters as defined in
0 commit comments