Javascript Jquery文件分块压缩和上载
我一直在尝试实现文件压缩,然后将压缩后的文件分块上传 对于文件压缩,我使用了:Javascript Jquery文件分块压缩和上载,javascript,jquery,file-upload,compression,chunks,Javascript,Jquery,File Upload,Compression,Chunks,我一直在尝试实现文件压缩,然后将压缩后的文件分块上传 对于文件压缩,我使用了: var maxWidth = 960, maxHeight = 960, imageWidth = image.width, imageHeight = image.height; if (imageWidth > imageHeight) { if (imageWidth > maxWidth) {
var maxWidth = 960, maxHeight = 960, imageWidth = image.width,
imageHeight = image.height;
if (imageWidth > imageHeight) {
if (imageWidth > maxWidth) {
imageHeight *= maxWidth / imageWidth;
imageWidth = maxWidth;
}
}
else {
if (imageHeight > maxHeight) {
imageWidth *= maxHeight / imageHeight;
imageHeight = maxHeight;
}
}
var canvas = document.createElement('canvas');
canvas.width = imageWidth;
canvas.height = imageHeight;
var ctx = canvas.getContext("2d");
ctx.drawImage(this, 0, 0, imageWidth, imageHeight);
// The resized file ready for upload
var finalFile = canvas.toDataURL(fileType);
这将返回base64格式
但对于文件分块上传,我使用了一些只接受文件而不接受base64格式的技术:(
我的区块上传代码如下:
cful = Object.create(chunkedFileUploader);
cful.init(item.file(), item.messageid(), '', item.messageid(), false, item.height, item.width);
//self.uploaderCollection.push(cful);
cful.uploadMetaData();
有没有办法:
1) 压缩后获取文件而不是base642) 接受base64进行区块上传。
3) 或者有没有其他更好的方法来解决这些复杂问题 提前感谢:)