-
-
Notifications
You must be signed in to change notification settings - Fork 207
an example for saving image with ParseFile #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @alparslantopbas, var file = await _downloadFile(
"https://i2.wp.com/blog.openshift.com/wp-content/uploads/parse-server-logo-1.png",
"image.png");
print("saveFile");
ParseFile parseFile = ParseFile(file, name: "image.png", debug: true);
var fileResponse = await parseFile.save();
if (fileResponse.success) {
parseFile = fileResponse.result as ParseFile;
print(parseFile.toString());
print("Upload with success");
} else {
print("Upload with failed");
} |
Thanks for the quick response, but I think this code is for file download. How can I upload a file to ParseServer ? imageOnYuz.name = randomAlphaNumeric(10) + '.png'; ParseObject images = new ParseObject(tblImages); var imagesResponse = await images.save(); |
Hi @alparslantopbas , This code is not for download from the archive. The file download was just to create a file in the local store. The file can be an image selected through the image_picker plugin. The ParseFile constructor needs the File and the file name. The Debug parameter is optional. After saving ParseFile you can save it to a ParseObject. See the example below File image = await ImagePicker.pickImage(source: ImageSource.gallery);
ParseFile parseFile = ParseFile(image, name: "image.jpg", debug: true);
var fileResponse = await parseFile.save();
if (fileResponse.success) {
parseFile = fileResponse.result as ParseFile;
print(parseFile.toString());
print("Upload with success");
} else {
print("Upload with failed");
return;
}
var parseObject = ParseObject("TestObjectFile", debug: true);
parseObject.set<ParseFile>("fileImage", parseFile);
var apiResponse = await parseObject.save();
if (apiResponse.success) {
print('ok');
} else {
print("Error: " + apiResponse.error.toString());
} |
Hi @RodrigoSMarques , Thank you very much, it works 👍 |
could you please, can you give a basic working example an image save/upload with ParseFile to Parse Server?
The text was updated successfully, but these errors were encountered: