- Home /
Downsize/compress image on upload to Firebase?
The images that i upload to FIrebase are pretty big and i need way to make them smalles in bytes size. I only found stuff about Bitmap on other sites but unity does not recognise it and i dont know why. I use the Unity asses SimpleFile Browser for the selection of the file` IEnumerator ShowLoadDialogCoroutine() { yield return FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.FilesAndFolders, true, null, null, "Load Files and Folders", "Load"); Debug.Log(FileBrowser.Success);
if (FileBrowser.Success)
{
for (int i = 0; i < FileBrowser.Result.Length; i++)
Debug.Log(FileBrowser.Result[i]);
Debug.Log("File Selected");
byte[] bytes = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result[0]);
long x = FileBrowserHelpers.GetFilesize(FileBrowser.Result[0]);
Debug.LogError(x);
var newMetaData = new MetadataChange();
newMetaData.ContentType = "image/jpeg";
if (haspp == 1)
{
StartCoroutine(DeleteProfilePic());
}
StorageReference uploadRef = reference.Child("profilePictures").Child(User.UserId).Child("picture");
Debug.Log("File Upload started");
uploadRef.PutBytesAsync(bytes, newMetaData).ContinueWithOnMainThread((task) =>
{
if (task.IsFaulted || task.IsCanceled)
{
Debug.Log(task.Exception);
}
else
{
Debug.Log("File uploaded succesfully");
}
});
StorageReference image = reference.Child("profilePictures").Child(User.UserId).Child("picture");
image.GetDownloadUrlAsync().ContinueWithOnMainThread(task =>
{
if (!task.IsCanceled && !task.IsFaulted)
{
StartCoroutine(LoadImage(task.Result.ToString()));
}
else
{
Debug.Log(task.Exception);
}
});
}
}`
if anybody knows a way i would be so greatful
Your answer
Follow this Question
Related Questions
How to upload an image from our system or device 2 Answers
Can't display image from URL using MySQL 000webhost 2 Answers
SQLite, BLOB and UI Image 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers