mime-types 相关问题

MIME(多用途Internet邮件扩展)之后的MIME类型是Internet上文件格式的两部分标识符。

Django 管理员突然仅在生产环境中注销(拒绝执行脚本,因为其 MIME 类型('text/html')不可执行)

每当我在 django 管理员上执行保存、更新或过滤某些操作时,就有可能重定向到登录页面,并且需要再次登录。这种行为经常发生...

回答 2 投票 0

如何使用 JMeter 将 application/x-www-form-urlencoded 参数发送到 RestServer?

我开发了一个休息服务器,并将其在本地主机中运行,我尝试使用 JMeter 执行测试,发送请求帖子和获取(取决于调用的方法)。 我已经发送到 Rest 服务器...

回答 6 投票 0

使用 Laravel Mailable 发送附件时 Symfony MIME 部分出现类型错误

上下文: 我正在开发一个 Laravel 应用程序,我需要使用自定义 Mailable 类 (PdfEmail) 发送带有附件的电子邮件。电子邮件应包含动态生成的 PDF 和其他内容

回答 1 投票 0

我们如何将八位字节格式的文件转换为其原始的mime类型文件?

在尝试从网站下载 PDF/Word/RTF 文件时,我发现下载按钮经检查后并不是直接链接。单击按钮后,文件开始下载,...

回答 1 投票 0

尝试获取 docx 文件上的 mime 类型会导致 application/octet-stream

我正在尝试验证 Laravel 上的文件上传(仅限 docx),但它一直失败。经过一番研究,它归结为 $request->file('file')->getMimeType() 和 mime_content_type($request-&g...

回答 2 投票 0

获取MediaSource.isTypeSupported的mime类型

如何获取需要通过 ffprobe/ffmpeg 传递给 MediaSource.isTypeSupported 的 Mime 类型? 例如,在我的计算机上,返回 true: MediaSource.isTypeSupported('video/mp4; codecs="avc1.

回答 4 投票 0

哪种是 FLAC 的“正确”内容类型?

某些软件使用音频/flac。有些使用audio/x-flac。 MDN 认为 x-flac 是“非标准”。但基于什么? 但这似乎是音频/类型的官方注册表......并且......

回答 2 投票 0

如何在网络上找到文件网址的 MIME 类型

有没有办法检查我从 URL 加载的文件是图像还是视频。 如何区分图像类型和视频类型并在我的网页上相应地解析它们。 我正在使用...

回答 1 投票 0

由于不允许的 MIME 类型(“text/html”),从“http://localhost/js/third.module.js”加载模块被阻止

我正在尝试使用 Three.module.js,但要让它正常工作要受 MIME 类型阻止的困扰,我正在使用 xampp 作为本地主机(我设置了 xampp 以允许 .js类型也作为尝试

回答 1 投票 0

CodeIgniter:“不允许您尝试上传的文件类型。”

我遇到了一个非常奇怪的上传问题。这是相关的视图文件: 我遇到了一个非常奇怪的上传问题。这是相关的视图文件: <form action="http://localhost/index.php/temp/upload/" method="post" enctype="multipart/form-data"> <fieldset> <input type="file" name="userfile"/> <input type="submit" value="Upload"/> </fieldset> </form> 这是我的 temp 控制器的 upload() 方法: public function upload() { $config['upload_path'] = FCPATH . 'uploads' . DIRECTORY_SEPARATOR; assert(file_exists($config['upload_path']) === TRUE); $config['allowed_types'] = 'avi|mpg|mpeg|wmv|jpg'; $config['max_size'] = '0'; $this->load->library('upload', $config); if ($this->upload->do_upload('userfile') === FALSE) { // Some error occured var_dump($this->upload->display_errors('', '')); var_dump($_FILES); } else { // Upload successful var_dump($this->upload->data()); } } 当我上传 AVI 视频时,一切正常。当我上传 WMV 视频时,我会得到以下 var 转储: string 'The filetype you are attempting to upload is not allowed.' (length=57) array 'userfile' => array 'name' => string 'wmv.wmv' (length=7) 'type' => string 'video/x-ms-wmv' (length=14) 'tmp_name' => string 'C:\wamp\tmp\php2333.tmp' (length=23) 'error' => int 0 'size' => int 83914 “wmv”扩展名被解释为 MIME 类型:video/x-ms-wmv。这应该没问题,因为我的 config/mimes.php 有以下内容: 'wmv' => array('video/x-ms-wmv', 'audio/x-ms-wmv') 当我尝试上传其他文件时,也是类似的情况。到目前为止,唯一有效的似乎是我的测试 AVI 视频。 有什么想法可能是错的吗? 更新1: 我的一台机器,只上传AVI。在另一位开发人员的计算机上,没有文件上传。在另一台开发人员的机器上,所有支持的文件都会上传。这些是浏览器还是服务器问题? 您正在使用 Firefox,不是吗? 你可以尝试查看system/libraries/Upload.php第199行: $this->_file_mime_type($_FILES[$field]); 将该行更改为: $this->_file_mime_type($_FILES[$field]); var_dump($this->file_type); die(); 然后上传您的 .wmv 文件。它会显示类似 application/octet-stream 之类的东西。将其添加到您的mimes.php。希望这有帮助 =) 类似答案这里 一些链接: CodeIgniter 论坛主题 Firefox 中的 Mimetype 损坏 绕过 IE 的 MIME 类型修改 $config["allowed_types"] ="*"; 使用 FTP/SFTP/scp/etc 将 .wmv 文件上传到运行 CodeIgniter 应用程序的服务器 在您上传.wmv文件的服务器上,执行以下PHP代码 <?php $file_path = 'CHANGE_THIS_TO_ABSOLUTE_FILE_PATH_THAT_YOU_HAVE_UPLOADED.wmv'; $finfo = finfo_open(FILEINFO_MIME); $mime = finfo_file($finfo, $file_path); var_dump($mime); ?> 将代码另存为mime.php 在终端中运行 - $ php mime.php 如果它转储除 wmv 已有的任何其他值,请将该值附加到 wmv mime 类型中。 还要检查其他开发机器上的 PHP_VERSION。 finfo_open 是在 PHP 5.3 中引入的。上传工作的开发机器可能有旧版本的 PHP,或者可能有适合 wmv 的 mime 类型。 您是否尝试在 $config['allowed_types'] 中使用 mime 类型而不是扩展名? 这样写 $config["allowed_types"] = "video/x-msvideo|image/jpeg|video/mpeg|video/x-ms-wmv"; 在 CodeIgniter 中上传 .doc 文件的答案 改变这个 'doc' => 'application/msword', 第 95 行(application/config/mimes.php 文件) 'doc' => array('application/vnd.ms-word','application/msword'), 我最近在使用 Codeigniter 的 Upload 类时遇到了一些非常类似的问题。 *allowed_types* 似乎不起作用。例如,我想允许上传 .PNG 图像,但不允许它们通过其过滤器。我最终进一步调查了它。我允许临时上传所有文件类型,上传了 .PNG,然后转储上传数据 ($this->upload->data());)。由于某种原因,它认为 MIME 类型是 text/plain!这可能与您的问题有关。 我在一些论坛上找到了一些解决方案,您可以在其中修改/扩展类或核心,但它们对我不起作用 - 抱歉。我相信这是一个 Codeigniter Core 错误(我认为这个问题已经由 EllisLabs 提出)。无论如何,我最终还是对这该死的东西进行了硬编码!嗯,希望这对您有所帮助。 基本示例/解决方法, //replace with your allowed MIME types if ($_FILES['name_of_form_upload']['type'] != 'image/jpeg' && $_FILES['name_of_form_upload']['type'] != 'image/png' && $_FILES['name_of_form_upload']['type'] != 'image/gif') { $data['message'] = '<div class="message">That file type is not allowed!</div>'; $this->load->view('home_view', $data); } else { //run upload code } 编辑:格式/语法 检查 application/config 中的 mimes.php 文件。它应该返回一个 mime 类型数组,例如文件末尾的 return $mimes; 或 mime 数组开头的 return array(.....。 对于 Codeigniter 3.1.7,如果您通过 $config['file_name'] 提供自定义文件名,请确保文件名也具有文件扩展名。 这实际上是核心中的一个错误。我升级到最新版本的 CI,错误消失了。 如果您需要简单的方法来解决这个问题,有一个简单的解决方案。 打开“system/libraries/Upload.php”文件 line no 465 you will see if ( ! $this->is_allowed_filetype()) { $this->set_error('upload_invalid_filetype', 'debug'); return FALSE; } just make it true if ( ! $this->is_allowed_filetype()) { $this->set_error('upload_invalid_filetype', 'debug'); return TRUE; } note : it will stop your all file type validation. 申请变更

回答 11 投票 0

Android 从 URI 起始内容打开 PDF

我正在尝试使用以下意图打开 PDF: 这是我的代码: 意图意图=新意图(Intent.ActionVIEW) intent.setDataAndType(Uri.parse("CONTENTURI +

回答 1 投票 0

我如何使用 ActivityResultLauncher.GetContent() 请求多个 MIME 类型?

我试图从用户那里检索一个可以是图像或pdf的文件,使用 registerForActivityResult(ActivityResultContracts.GetContent()) { 文件:Uri -> ...... }.启动( 我正在尝试使用从用户那里检索一个可以是图像或pdf的文件 registerForActivityResult(ActivityResultContracts.GetContent()) { file: Uri -> ...... }.launch(<mimetypes>) 我已经尝试过另一个问题的答案中的"image/*|application/pdf",但它不起作用,有没有办法在使用registerForActivityResult时要求多种MIME类型? 使用 registerForActivityResult 时有什么方法可以请求多个 MIME 类型吗? 不能直接使用当前版本的ActivityResultContracts.GetContent。但是,您应该能够对其进行子类化、覆盖 createIntent(),并从那里自定义生成的 Intent。然后,您可以尝试将 EXTRA_MIME_TYPES 添加到该 Intent 以及您想要的其他 MIME 类型的 String[]。 这是我的示例代码,在 api 31 中测试 var resultGalleryLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> if (result.resultCode == Activity.RESULT_OK) { val intent: Intent? = result.data if (intent != null) { intent.data?.let { selectedImageUri -> .... } } } else { Timber.e(" >>> error selected image from gallery by intent") } } } fun galleryLauncher() { val intent = Intent(Intent.ACTION_GET_CONTENT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI).apply { type = "image/*" action = Intent.ACTION_GET_CONTENT putExtra(Intent.EXTRA_MIME_TYPES, arrayOf("image/jpeg", "image/png", "image/jpg")) putExtra(Intent.EXTRA_ALLOW_MULTIPLE, false) } resultGalleryLauncher.launch(intent) } 请使用 ActivityResultContracts.OpenMultipleDocuments() 来代替。 import androidx.activity.result.contract.ActivityResultContracts class DocumentsFragment : Fragment() { companion object { // 1. List of MIME types /**@see <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types">MIME types</a> * @see <a href="https://www.iana.org/assignments/media-types/media-types.xhtml">IANA - MIME types</a>*/ private val MIME_TYPES: Array<String> = arrayOf( "image/*", "application/pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.oasis.opendocument.text", "text/plain", "text/markdown" ) } //2. Register for Activity Result callback as class field private val getDocuments = registerForActivityResult(ActivityResultContracts.OpenMultipleDocuments()/*NOT OpenDocument*/) { Log.d("Open documents", "incoming uri: size = ${it.size}") add(it) } ... //3. set onclick listener selectDocumentsButton.setOnClickListener { getDocuments.launch(MIME_TYPES) } ... //4. handle incoming uri list private fun add(list: List<Uri>) { val setOfFiles = copyToAppDir(list) setOfFiles.forEach { //TODO: do something } } //5. copy the files to the application folder for further work private fun copyToAppDir(list: List<Uri>): Set<File> { val set = mutableSetOf<File>() list.forEach { uri -> try { val file: File = copyUriContentToTempFile(uri) set.add(file) } catch (e: Exception) { e.printStackTrace() } } return set } //6. copy selected content by uri private fun copyUriContentToTempFile(uri: Uri): File { val inputStream = requireContext().contentResolver.openInputStream(uri) inputStream.use { input -> val tempFile: File = .. ; //TODO: create file tempFile.outputStream().use { output -> input?.copyTo(output) } return tempFile } } } 将建议的解决方案从 Kotlin 翻译为 Java,以防有人需要: ActivityResultLauncher<Intent> photoPicker2 = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { if(result.getResultCode() == Activity.RESULT_OK) { Intent intent = result.getData(); if(intent != null) { Uri picked = intent.getData(); if(picked != null) { //Process the image... } } } }); 调用启动器: try { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[]{"image/jpeg", "image/png", "image/x-png"}); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); photoPicker2.launch(intent); } catch (ActivityNotFoundException e) { try { //Fallback to ActivityResultContracts.OpenDocument(). documentPicker.launch(new String[]{"image/jpeg", "image/png", "image/x-png"}); } catch (ActivityNotFoundException ignore) {} }

回答 4 投票 0

在 Android 应用程序中读取 CSV 文件的 MIME 类型不起作用

也许我可以在这里得到帮助。我正在使用 Java 开发 Android 应用程序,并尝试选择 .csv 文件来导入一些数据: 公共无效onButtonImportClick(查看视图){ Log.d(TAG, "

回答 1 投票 0

确定 Ruby 中的文件类型

如何可靠地确定文件的类型?文件扩展名分析是不可接受的。一定有一个类似于 UNIX file(1) 命令的 rubyesque 工具吗? 这与 MIME 或内容类型有关...

回答 13 投票 0

在 nginx 上部署 Angular 15 项目,服务器响应 MIME 类型为“text/html”?

我正在使用 docker 文件通过 nginx 服务器将角度应用程序部署到域,我的部署角度路径是 /domain/ui/ 但问题是部署后我遇到了上述错误。 **> 无法加载模块

回答 1 投票 0

使用 WordPress wp_mail() 的电子邮件标题无效

当我尝试使用 WP Mail SMTP 发送电子邮件时,收到无效标头,测试电子邮件工作正常。从 25.01 开始,它已经完美运行了几个月。它不工作。 我的代码: $标题=&...

回答 1 投票 0

如何设置application/vnd.apple.pkpass的MIME类型以便通过链接或电子邮件共享pass

我刚刚创建了一个应用程序和一张通行证,因此我可以将通行证添加到 iPod 中的 PassBook,但我无法通过电子邮件或来自网络服务器的链接共享通行证。从我从苹果读到的文档中,我需要广告......

回答 6 投票 0

“拒绝应用 {link} 中的样式,因为其 MIME 类型不受支持且启用了严格的 MIME 检查。”在 Vue+Vuetify 应用程序中

我使用 vue-create-app 创建了一个 Vue+Vuetify 项目。在我的本地系统中,Vuetify 工作正常,但在 Gitlab 实时服务器上不起作用。并在实时应用程序中显示此错误消息: “拒绝应用...

回答 1 投票 0

npm 包 mime 类型无法与打字稿(或 Nestjs)一起工作(给出未定义)

我尝试在 NestJs 中使用 mime 类型,如下所示。 从“mime-types”导入 mime; mime.contentType(req.url) 但是即使我已经安装了 mime-types npm 包,mime 也给了我未定义的信息。它确实...

回答 2 投票 0

如何使用 mime 类型 octet-stream 从无扩展名的文件中提取文件扩展名?

我有大量文件,它们的原始文件名已被数据库中的 id 替换。例如,曾经的名称 word_document.doc 现在是 12345。通过一个过程,我...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.