await Supabase.initialize(
url: "https://${Environment.supabaseUrl}.supabase.co",
anonKey: Environment.supabaseAnon,
debug: !kReleaseMode,
);
...
File? fileToUpload;
try {
///
/// We first need to transfer the base64 content to a real file
///
fileToUpload = await FileHelper().writeStringToFile('temp', 'profile_picture.png', base64Content.replaceAll('base64:', ''));
///
/// Now, we need to upload the file onto the Storage bucket
///
final StorageResponse<String> storageResponse = await Supabase.instance.client.storage.from('avatars').upload(
'avatar1.jpg',
fileToUpload,
fileOptions: const FileOptions(cacheControl: '3600', upsert: true),
);
if (storageResponse.hasError) {
log('STORAGE ERROR => ${storageResponse.error}');
} else {
log('STORAGE SUCCESS => ${storageResponse.data}');
}
} catch (e) {
// Nothing
log('STORAGE ERROR (Exception)=> $e');
} finally {
if (fileToUpload != null) {
fileToUpload.delete();
}
}
await Supabase.initialize(
url: "https://${Environment.supabaseUrl}.supabase.co",
anonKey: Environment.supabaseAnon,
debug: !kReleaseMode,
);
...
File? fileToUpload;
try {
///
/// We first need to transfer the base64 content to a real file
///
fileToUpload = await FileHelper().writeStringToFile('temp', 'profile_picture.png', base64Content.replaceAll('base64:', ''));
///
/// Now, we need to upload the file onto the Storage bucket
///
final StorageResponse<String> storageResponse = await Supabase.instance.client.storage.from('avatars').upload(
'avatar1.jpg',
fileToUpload,
fileOptions: const FileOptions(cacheControl: '3600', upsert: true),
);
if (storageResponse.hasError) {
log('STORAGE ERROR => ${storageResponse.error}');
} else {
log('STORAGE SUCCESS => ${storageResponse.data}');
}
} catch (e) {
// Nothing
log('STORAGE ERROR (Exception)=> $e');
} finally {
if (fileToUpload != null) {
fileToUpload.delete();
}
}