У меня есть приложение Flutter Firebase, и я пытаюсь отслеживать прогресс загрузки видео с момента, как оно выбрано из Google Drive < /p>
через наблюдение, я понимаю, что Google Drive Первые загрузки Видео на устройство затем загружает его в хранилище Firebase, но в течение времени оно загружается с диска на устройство, я не могу отслеживать его, вот код, который я использую для загрузки файлов и отслеживания прогресса < /p>
Align(
alignment: const AlignmentDirectional(0.0, -1.0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Align(
alignment: const AlignmentDirectional(0.0, 0.0),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Align(
alignment:
const AlignmentDirectional(0.0, -1.0),
child: Text(
FFLocalizations.of(context).getText(
'ayvkafvm' /* Upload Video */,
),
textAlign: TextAlign.center,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily:
FlutterFlowTheme.of(context)
.bodyMediumFamily,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyMediumFamily),
),
),
),
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(
0.0, 0.0, 17.0, 0.0),
child: FlutterFlowIconButton(
borderColor: Colors.transparent,
borderRadius: 30.0,
borderWidth: 1.0,
buttonSize: 40.0,
icon: Icon(
Icons.video_call,
color:
FlutterFlowTheme.of(context).primary,
size: 24.0,
),
onPressed: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles(
type: FileType.video,
allowMultiple: false,
);
if (result != null) {
File file =
File(result.files.single.path!);
String fileName =
result.files.single.name;
try {
final Reference storageRef =
FirebaseStorage.instance
.ref()
.child('videos/$fileName');
final UploadTask uploadTask =
storageRef.putFile(file);
// Show upload progress
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
content:
StreamBuilder(
stream:
uploadTask.snapshotEvents,
builder: (context, snapshot) {
if (snapshot.hasData) {
final progress = snapshot
.data!
.bytesTransferred /
snapshot
.data!.totalBytes;
return Column(
mainAxisSize:
MainAxisSize.min,
children: [
CircularProgressIndicator(
value: progress),
const SizedBox(
height: 10),
Text(
'${(progress * 100).toStringAsFixed(2)}%'),
const SizedBox(
height: 10),
Text(
'Uploading: ${fileName}'),
],
);
} else {
return const SizedBox();
}
},
),
);
},
);
// Wait for the upload to complete
await uploadTask;
// Get the download URL
String downloadURL =
await storageRef.getDownloadURL();
// Close the progress dialog
Navigator.of(context).pop();
// Update the model with the new URL
setState(() {
_model.uploadedFileUrl1 =
downloadURL;
});
// Clear cache after successful upload
await DefaultCacheManager()
.emptyCache();
ScaffoldMessenger.of(context)
.showSnackBar(
const SnackBar(
content: Text(
'Video uploaded successfully')),
);
} catch (e) {
print('Error uploading video: $e');
ScaffoldMessenger.of(context)
.showSnackBar(
const SnackBar(
content: Text(
'Failed to upload video')),
);
}
}
},
),
),
],
),
),
],
),
),
Подробнее здесь: https://stackoverflow.com/questions/793 ... ogle-drive
Отслеживание скачать прогресс с Google Drive [закрыто] ⇐ Android
Форум для тех, кто программирует под Android
-
Anonymous
1737690333
Anonymous
У меня есть приложение Flutter Firebase, и я пытаюсь отслеживать прогресс загрузки видео с момента, как оно выбрано из Google Drive < /p>
через наблюдение, я понимаю, что Google Drive Первые загрузки Видео на устройство затем загружает его в хранилище Firebase, но в течение времени оно загружается с диска на устройство, я не могу отслеживать его, вот код, который я использую для загрузки файлов и отслеживания прогресса < /p>
Align(
alignment: const AlignmentDirectional(0.0, -1.0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Align(
alignment: const AlignmentDirectional(0.0, 0.0),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Align(
alignment:
const AlignmentDirectional(0.0, -1.0),
child: Text(
FFLocalizations.of(context).getText(
'ayvkafvm' /* Upload Video */,
),
textAlign: TextAlign.center,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily:
FlutterFlowTheme.of(context)
.bodyMediumFamily,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyMediumFamily),
),
),
),
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(
0.0, 0.0, 17.0, 0.0),
child: FlutterFlowIconButton(
borderColor: Colors.transparent,
borderRadius: 30.0,
borderWidth: 1.0,
buttonSize: 40.0,
icon: Icon(
Icons.video_call,
color:
FlutterFlowTheme.of(context).primary,
size: 24.0,
),
onPressed: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles(
type: FileType.video,
allowMultiple: false,
);
if (result != null) {
File file =
File(result.files.single.path!);
String fileName =
result.files.single.name;
try {
final Reference storageRef =
FirebaseStorage.instance
.ref()
.child('videos/$fileName');
final UploadTask uploadTask =
storageRef.putFile(file);
// Show upload progress
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
content:
StreamBuilder(
stream:
uploadTask.snapshotEvents,
builder: (context, snapshot) {
if (snapshot.hasData) {
final progress = snapshot
.data!
.bytesTransferred /
snapshot
.data!.totalBytes;
return Column(
mainAxisSize:
MainAxisSize.min,
children: [
CircularProgressIndicator(
value: progress),
const SizedBox(
height: 10),
Text(
'${(progress * 100).toStringAsFixed(2)}%'),
const SizedBox(
height: 10),
Text(
'Uploading: ${fileName}'),
],
);
} else {
return const SizedBox();
}
},
),
);
},
);
// Wait for the upload to complete
await uploadTask;
// Get the download URL
String downloadURL =
await storageRef.getDownloadURL();
// Close the progress dialog
Navigator.of(context).pop();
// Update the model with the new URL
setState(() {
_model.uploadedFileUrl1 =
downloadURL;
});
// Clear cache after successful upload
await DefaultCacheManager()
.emptyCache();
ScaffoldMessenger.of(context)
.showSnackBar(
const SnackBar(
content: Text(
'Video uploaded successfully')),
);
} catch (e) {
print('Error uploading video: $e');
ScaffoldMessenger.of(context)
.showSnackBar(
const SnackBar(
content: Text(
'Failed to upload video')),
);
}
}
},
),
),
],
),
),
],
),
),
Подробнее здесь: [url]https://stackoverflow.com/questions/79380252/tracking-download-progress-from-google-drive[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия