Skip to main content
Version: 3.0.0

📤 Upload Media File

Upload a Media File to Business Account

var upload = await whatsapp.uploadMediaFile(
file: File('assets/sample.png'),
fileType: 'image/png',
);

upload.getMediaId(); //10023589340434
paramtyperequireddescription
fileFileyesFile Path.
fileTypeStringyesFile Type (ex. image/png)
Supported Media Type

Please make sure you are using correct media types, Please find out supported media type here.

Some Tips

Here is some tips to media using image_picker Package and file_picker Package

For Image :-

 final ImagePicker _picker = ImagePicker();
final XFile? image = await _picker.pickImage(source: ImageSource.gallery);
await whatsapp.uploadMediaFile(
file: image.path,
fileType: 'image/png'
);

For Image, Audio, Video, Document or any file :-

 FilePickerResult? result = await FilePicker.platform.pickFiles();
PlatformFile file = result.files.first;
await whatsapp.uploadMediaFile(
file: file.path,
fileType: 'application/pdf'
);

Media Return Methods