I want to get my audio file in my appwrite storage, I am using the getFileView , when we trigger this method it will return a buffer of our audio file. Next is I am using audio_player package in flutter. How can I load my audio file as buffer then?
hi
In web, those methods give you URL. You then use any client to download it as buffer - but since you are using Flutter, let me see how it could be done in it
sorry for late reply, I already fix it this issue thank you
Hey @Mosh Ontong - you can let me know your issue
This is how I get the audo files from my appwrite storage
final id = e['\$id'];
final storage = Storage(ref.read(appwriteClientProvider));
final url = await storage.getFileView(bucketId: kAudioBucketId, fileId: id);
final audioItem = AudioLanguage.fromDocument(e);
return audioItem.copyWith(
audioFileBytes: url,
And this is the summary of my AudioLanguage model btw
const AudioLanguage({
required this.id,
required this.name,
required this.vocabularyId,
required this.sexVoice,
this.audioFileBytes,
this.bitrate,
this.sampleRate,
this.duration,
this.channel,
});
final String id;
final String name;
final String vocabularyId;
final Uint8List? audioFileBytes;
final Sex sexVoice;
final int? channel;
final int? sampleRate;
final double? bitrate;
final double? duration;
is there another way to get the view as url of my audio, just the image shows to us,
ms @joeyouss
To add more information
Basically, I am using the audio_player package in flutter. Though they have this setSource(ByteSource(value)). But according to their documentation
the ByteSource is only some platforms. I am actually creating a flutter windows, it seems that ByteSource is not compatible in flutter windows. That is why, I want to find another way like I want to get the exact url of my audio file
I am actually using this but this is not safe, though we can set up the permission of the bucket but the problem is that when I accessing that url with a permision that only user can access. It gives me unauthorized access. Thats why I think we have to create another method that can get the url
Thank you for sharing it here @Mosh Ontong . getFileView actually gives the data (file) https://github.com/appwrite/sdk-for-flutter/blob/master/lib/services/storage.dart#L203 - it gives you a Uint8list and whatever library you are using should be able to take that as input - I see you are using ByteSource but it has a limitation so you might want to use URLsource provided in audio_player? but you would need the file URL for which I recommend: https://github.com/appwrite/appwrite/discussions/3474
Recommended threads
- Appwrite (Dart SDK) (for package_info_pl...
Hi team! Many Flutter plugins now need package_info_plus 10.x and device_info_plus 13.x, but appwrite 25.4.0 still constrains package_info_plus: >=8.0.2 <10.0...
- Images/Videos in storage appearing broke...
I am running into a storage issue after upgrading my self-hosted Appwrite instance , all of my previously uploaded images and videos are now showing as broken i...
- `project_id_missing` in Cloud Function w...
I've got a cloud function written in `Dart-3.12` that I'm trying to create a file in a file bucket. I'm using the latest `dart_appwrite` sdk (`26.1.0`) and App...