Skip to main content
Version: 4.0.0

📦 Create & Upload Resumable

Create and upload a resumable file at once

await whatsapp.createUploadResumableFile(
fileLength: 210915,
file: File('sample_files/resumable-sample.png'), // use any one file or fileUrl
fileUrl: 'http://raw.githack.com/rohit-chouhan/whatsapp/main/sample_files/resumable-sample.png',
fileType: 'image/png',
fileName: 'resumable-sample.png',
);

Example

A example with select image (using file picker) and update business profile photo. 👉 Check out this working example here: pub.dev WhatsApp Example

FilePickerResult? result = await FilePicker.platform.pickFiles(type: FileType.image, allowedExtensions: ['png']);
if (result != null) {
try {
final uploadResponse = await whatsapp.createUploadResumableFile(
fileLength: result.files.first.size,
file: File(result.files.first.path!),
fileType: 'image/png',
fileName: result.files.first.name);
await whatsapp.updateBusinessProfile(
profilePictureHandle: uploadResponse.getH(),
);
print('Profile picture updated');
} catch (e) {
print('Error updating profile picture: $e');
}
}
warning

Use either file or fileUrl, not both.
If you provide file, omit fileUrl.
If you provide fileUrl, omit file.
Choose the option that best fits your use case.

paramtyperequireddescription
fileLengthintyesExact file size in bytes
fileFilenoFile that you are going to upload
fileUrlStringnoDirect file url to upload
fileTypeStringyesType of file that you are going to upload
fileNameStringnoName of the file

Web Platform

Most features work seamlessly on Flutter Web, however uploadResumableFile and createUploadResumableFile won't work due to CORS restrictions imposed by the WhatsApp Business API. Direct uploads from web browsers to external APIs are blocked for security reasons by meta.

Workaround for Web Uploads:

  • Implement a backend server to proxy upload requests
  • Upload files to your server first, then use uploadResumableFileByUrl with a public URL
  • For development, consider using mobile platforms or desktop builds

Resumable Return Methods