
I want to upload some file from client side into the server cloud function. I want to bring that file in my appwrite function, How to do this?

You should be able to use the platform specific approach to send a file in a request. I havenβt had to do this yet, so not sure

currently I am using flutter

From the top of my head, you could convert the image into a base64 string, and send it to the server where you can decode it

ohh I seee

This is the answer of Appwrite AI:
import 'package:http/http.dart' as http;
import 'dart:io';
void sendFileToCloudFunction(File file) async {
var request = http.MultipartRequest(
'POST',
Uri.parse('YOUR_CLOUD_FUNCTION_ENDPOINT'),
);
// Add the file to the request
var fileStream = http.ByteStream(file.openRead());
var length = await file.length();
var multipartFile = http.MultipartFile('file', fileStream, length,
filename: file.path.split('/').last);
request.files.add(multipartFile);
// Send the request
var response = await request.send();
// Handle the response
if (response.statusCode == 200) {
print('File uploaded successfully');
} else {
print('Error uploading file: ${response.reasonPhrase}');
}
}
What do you think is this works?
PS: I need your help @Meldiron I just want to validate the code if valid

If you're using the custom function endpoint, you can send a file just like you would any other API endpoint

Yes, multipartfile is the way to go

Please don't tag people like this as it can be very disruptive

sorry
Recommended threads
- I am facing this error: type 'Null' is ...
When attempting to fetch areas from the area collection, the application throws an error: "type 'Null' is not a subtype of type 'int.'" This issue originates in...
- Domain Verification failed
I think i did the step by step well but just not work. When I enter the page I have this error: `Requested host does not match any Subject Alternative Names (S...
- Adding Domain to Sites [Self Hosted]
I am struggling to get this working. I stood-up a new server and deployed appwrite 1.7.4. I added update .env file _APP_DOMAIN=appwrite.mydomain.com _APP_DOMAI...
