fluttercommunity / fluttercommunity/flutter_uploader
Uploading video not recognized as video but image jpg
- Dominant language
- Dart
- Stars
- 218
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Description
Im following the example method on pub.dev about uploading image or video, as for the image its works great, but when i try to upload video, its not uploaded as video rather its uploaded as .jpg files too, i notice in example the mediatype for image is set to Video, but this just proves that its not recognizing whether it should upload video or image, take notes that there's nothing wrong with backend since i already test it with postman to upload video
`Future getImage({@required bool binary}) async {
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
if (image != null) {
final String filename = basename(image.path);
final String savedDir = dirname(image.path);
final tag = "image upload ${_tasks.length + 1}";
var url = _uploadUrl(binary: binary);
var fileItem = FileItem(
filename: filename,
savedDir: savedDir,
fieldname: "file",
);
var taskId = binary
? await uploader.enqueueBinary(
url: url,
file: fileItem,
method: UploadMethod.POST,
tag: tag,
showNotification: true,
)
: await uploader.enqueue(
url: url,
data: {"desc": "ofelia"},
files: [fileItem],
method: UploadMethod.POST,
tag: tag,
showNotification: true,
);
setState(() {
_tasks.putIfAbsent(
tag,
() => UploadItem(
id: taskId,
tag: tag,
type: MediaType.Image,
status: UploadTaskStatus.enqueued,
));
});
}
}
Future getVideo({@required bool binary}) async {
var video = await ImagePicker.pickVideo(source: ImageSource.gallery);
if (video != null) {
final String savedDir = dirname(video.path);
final String filename = basename(video.path);
final tag = "video upload ${_tasks.length + 1}";
final url = _uploadUrl(binary: binary);
var fileItem = FileItem(
filename: filename,
savedDir: savedDir,
fieldname: "file",
);
var taskId = binary
? await uploader.enqueueBinary(
url: url,
file: fileItem,
method: UploadMethod.POST,
tag: tag,
showNotification: true,
)
: await uploader.enqueue(
url: url,
data: {"desc": "randomVid"},
files: [fileItem],
method: UploadMethod.POST,
tag: tag,
showNotification: true,
);
setState(() {
_tasks.putIfAbsent(
tag,
() => UploadItem(
id: taskId,
tag: tag,
type: MediaType.MP4,
status: UploadTaskStatus.enqueued,
));
});
}
}`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.