Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploader Not Accepting FLAC Files #171

Closed
twinkietoes-on opened this issue Oct 31, 2023 · 3 comments
Closed

Uploader Not Accepting FLAC Files #171

twinkietoes-on opened this issue Oct 31, 2023 · 3 comments

Comments

@twinkietoes-on
Copy link
Collaborator

twinkietoes-on commented Oct 31, 2023

Our uploader at https://librivox.org/uploader used to accept FLAC files. It appears to no longer accept them, returning an error:

undefined NaN KB Error The filetype you are attempting to upload is not allowed.

This was first noticed end of December; I don't know if it was a problem earlier than that. It is just verified with at least 2 people, one exporting using Audacity and one using Sony Sound Forge.

@hamidsafdari
Copy link
Contributor

I tested the following files I found online and their MIME is set to audio/flac but the app only accepts audio/x-flac. Made that an array in application/config/mimes.php with the value array('audio/x-flac', 'audio/flac').

screenshot_2023-11-16_21-53_1
screenshot_2023-11-16_21-54
screenshot_2023-11-16_21-54_1

@hamidsafdari
Copy link
Contributor

I also found that some .mp3 files have a MIME type of application/octet-stream. The following patch fixes the issue (found on stackoverflow 😁 ) but I didn't include that in my pull request since application/octet-stream applies to a wide range of files. Waiting for someone's input on this.

diff --git a/application/libraries/MY_Upload.php b/application/libraries/MY_Upload.php
--- a/application/libraries/MY_Upload.php	(revision 9a742739aa3125233631854de5a35d9f8591f650)
+++ b/application/libraries/MY_Upload.php	(date 1700154035842)
@@ -46,4 +46,19 @@
 		return rename($path.$original, $path.$new_filename);
 	}
 
+	/**
+	 * Override application/octet-stream on file_type
+	 *
+	 * @param array $file
+	 * @return   void
+	 */
+	protected function _file_mime_type($file)
+	{
+		parent::_file_mime_type($file);
+
+		if ($this->file_type == 'application/octet-stream' && !empty($file['type']))
+		{
+			$this->file_type = $file['type'];
+		}
+	}
 }
\ No newline at end of file

@notartom
Copy link
Member

I also found that some .mp3 files have a MIME type of application/octet-stream. The following patch fixes the issue (found on stackoverflow 😁 ) but I didn't include that in my pull request since application/octet-stream applies to a wide range of files. Waiting for someone's input on this.

It's a good instinct to be weary of those files :) I think until someone reports it as being a problem, we can stick to solving the FLAC issue (which you have, thanks!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants