djade007 / cloudinary_public Goto Github PK
View Code? Open in Web Editor NEWA dart wrapper to upload media files to cloudinary
Home Page: https://pub.dev/packages/cloudinary_public
License: GNU General Public License v3.0
A dart wrapper to upload media files to cloudinary
Home Page: https://pub.dev/packages/cloudinary_public
License: GNU General Public License v3.0
On Flutter Web, I'm calling cloudStorage.multiUpload
and getting:
Error: Unsupported operation: MultipartFile is only supported where dart:io is available.
at Object.throw_ [as throw] (http://localhost:52896/dart_sdk.js:5342:11)
Is this expected? Seems like this might be an issue in Dio, so not sure exactly where to log it.
I am using this currently using Dio
final formData = FormData.fromMap({
'file': await MultipartFile.fromFile(
file.path,
),
'upload_preset': upload_preset,
'context': context,
});
Hello,
Ive look through this package and can't seem to find if it supports uploading of a video file of more than 100mb. When a video file is grater than 100mb you have to upload the video in chucks. Does this package support that or is it something that still needs to be implemented?
For a single file I do:
final List singleArray = [
myRent['documents'][i]["newDocument"].files.single
];
CloudinaryResponse expenseUrl = await cloudinary.uploadFile(
CloudinaryFile.fromFile(singleArray[0].path,
resourceType: CloudinaryResourceType.Auto),
);
But how can I use uploadFiles
(not multiUpload
) with and array of images?
This url from Cloudinary works: https://res.cloudinary.com/xxx/image/upload/s--KrQpnLn4--/c_thumb,w_200,g_face/v1/xxx/xxx.jpg
This one returned by plugin give 400 error: https://res.cloudinary.com/xxx/image/upload/c_thumb,g_face,w_200/s--q2NgOpl8--/v1617419988/xxx/xxx.jpg
Hi! How can I choose my path of upload in your package ?
Hi, I was trying Cloudinary_public to upload media to my cloudinary bucket.
It is working as intended for unsigned presets, but throws error for signed presets.
Any idea why this could be happening?
Thanks!
We're trying to upload images from a ByteData obtained from a Image.memory
; however this results in an invalid image payload. The bytedata can be correctly displayed as an image.
var data = //someUint8List
var buffer = ByteData.view(data)
CloudinaryResponse response = await cloudinary.uploadFile(
CloudinaryFile.fromByteData(buffer, resourceType: CloudinaryResourceType.Image),
);
This results in an invalid image file
however. We're trying to use cloudinary in conjunction with https://github.com/fluttercandies/flutter_image_editor.
When using the MultiImagePicker plugin, we're getting this error when trying to call cloudinary.uploadFile()
[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: FileSystemException: Cannot retrieve length of file, path = 'content://media/external/images/media/89894'
The same code works fine with image_picker. When I compare the returned paths, I see this:
multi_image_picker: "content://media/external/images/media/89894"
image_picker: "data/user/0/com.example.example/cache/image_picker6683537466962246256.jpg"
So it appears as though image_picker makes some local copy, and is required for uploads to work?
After installing dependencies:
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.3, on macOS 11.2.3 20D91 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] Connected device (2 available)
• No issues found!
I'm recording a video in an iOS Device (haven't tested in Android) with the image_picker package and then uploading it but I get this DioError:
{"error":{"message":"Image file format mov not allowed"}}
Here is my code:
final pickedFile = await _picker.getVideo(source: ImageSource.camera);
CloudinaryResponse response = await _cloudinaryPublic.uploadFile(
CloudinaryFile.fromFile(File(pickedFile.path), resourceType: CloudinaryResourceType.Video)
).catchError((error) {
return Future.error(error);
});
I have successfully uploaded an image, though.
Hi, can we use this to upload video and transform it?
I am using the standard way as per your documentation to upload a file. Everything work fine on the mobile app. However it seems to be unable to retrieve an URL when uploading from the Web.
Every try is followed by an "Invalid URL for upload".
I tried using the method fromByteData, fromFile, fromBytes. I suspect it is because it cannot create a path for the file ?
I viewed some of your answers but I couldn't make them work like this one
try {
CloudinaryFile cf =
CloudinaryFile.fromByteData(ByteData.sublistView(
await formResult.profilePic.readAsBytes(),
));
CloudinaryResponse response = await cloudinary.uploadFile(cf);
} on CloudinaryException catch (e) {
error = e;
}
The image is coming from a button:
GestureDetector(
onTap: () async {
final image = await ImagePicker()
.getImage(source: ImageSource.gallery);
if (image != null)
setState(() {
formResult.profilePic = image;
});
},
Is this plugins provide compression tools? like i pick 30MB video and compressed it to 2 MB - 4MB
i can see official document provide this
https://cloudinary.com/blog/how_to_automate_compression_of_video_files_with_one_line_of_code
@djade007
My use case requires me to programmatically set the name of the files I upload using the public_id
parameter. Unfortunately, your SDK doesn't seem to support using those parameters.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.