本文介绍了HTML5文件API - 切片与否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在上有一些很好的文件上传示例,但有对我来说是不够清楚的事情。

There are some nice examples about file uploading at HTML5 Rocks but there are something that isn't clear enough for me.

据我所知,关于从文件中获取特定部分然后读取它。正如笔记所说,当我们处理大文件时这很有用。

As far as i see, the example code about file slicing is getting a specific part from file then reading it. As the note says, this is helpful when we are dealing with large files.

关于还注意到当我们上传大文件时这很有用。

The example about monitoring uploads also notes this is useful when we're uploading large files.

我没有切片文件就安全了吗?我的意思是服务器端问题,内存等。目前Chrome不支持 File.slice(),如果可能,我不想使用膨胀的jQuery插件。

Am I safe without slicing the file? I meaning server-side problems, memory, etc. Chrome doesn't support File.slice() currently and i don't want to use a bloated jQuery plugin if possible.

推荐答案

Chrome和FF都支持 File.slice()但它在阅读.zip文件的一部分。新的语义是:

Both Chrome and FF support File.slice() but it has been prefixed as File.webkitSlice() File.mozSlice() when its semantics changed some time ago. There's another example of using it here to read part of a .zip file. The new semantics are:

Blob.webkitSlice(
  in long long start,
  in long long end,
  in DOMString contentType
);

你是否安全而不切片?当然,但请记住你正在将文件读入内存。 HTML5Rocks教程提供了上传内容作为潜在的性能改进。使用一些不错的服务器逻辑,您还可以更轻松地从失败的上传中恢复。如果99%的失败率,用户不必重新尝试整个500MB的文件:)

Are you safe without slicing it? Sure, but remember you're reading the file into memory. The HTML5Rocks tutorial offers chunking the upload as a potential performance improvement. With some decent server logic, you could also do things like recovering from a failed upload more easily. The user wouldn't have to re-try an entire 500MB file if it failed at 99% :)

这篇关于HTML5文件API - 切片与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 16:05