gpt4 book ai didi

javascript - Fine Uploader - 未从加载的 iframe 收到有效消息

转载 作者:行者123 更新时间:2023-11-28 07:31:19 25 4
gpt4 key购买 nike

尝试使现有的 Fine Uploader v4.2.2 实例与 IE8 兼容,但它返回“未从加载的 iframe 接收到有效消息”。

通读 3.3 和 3.7 CORS support博客文章 - 修改了我的 .net MVC 处理程序以检测非 XHR 请求并做出相应 react 。在客户端,已经将 CORS 属性“expected”设置为 true,但尝试将“sendCredentials”和“allowXdr”的组合设置为 true,但没有明显效果。

使用 Fiddler 确认我返回了正确的内容类型 (text/html),并且通常的 JSON 响应后面跟着一个脚本 block ,该脚本 block 指向“iframe.xss.response.js”的有效 URL - 尝试托管主 URL 和上传处理程序子域。

在当前的浏览器中,一切仍然运行得很好,只是感觉我在尝试支持 IE8 时遗漏了一些明显的东西。

这是我经过净化的 JS;

var fupParams = {
userId: 12345,
userKey: 67890
};

var fupInstance = $("#fine-uploader")
.fineUploader({
template: "qq-template",
thumbnails: {
placeholders: {
waitingPath: "/placeholders/waitingPath.gif",
notAvailablePath: "/placeholders/notAvailablePath.gif"
}
},
session: {
endpoint: "//upload.example.com/Upload/List",
params: fupParams
},
request: {
endpoint: "//upload.example.com/Upload/Upload",
params: fupParams
},
failedUploadTextDisplay: {
mode: "custom"
},
deleteFile: {
customHeaders: {},
enabled: true,
endpoint: "//upload.example.com/Upload/Delete",
method: "DELETE",
forceConfirm: true,
params: fupParams
},
validation: {
allowedExtensions: Array("jpg","png")
},
cors: {
expected: true,
sendCredentials: false
},
autoUpload: true,
editFilename: {
enabled: true
},
classes: {
success: "alert alert-success",
fail: "alert alert-error"
},
showMessage: function (message) {
// Simple event handler
}
})
.on("submit", function (event, id, name) {
// Use qq.Promise() to modify fupParams prior to upload
})
.on("submitDelete", function (event, id, name) {
// Use qq.Promise() to modify fupParams prior to delete
})
.on("error", function (event, id, name, errorReason, xhrOrXdr) {
// Simple event handler
})
.on("complete", function (event, id, name, response) {
// Simple event handler
})
.on("sessionRequestComplete", function (event, response, success, xhrOrXdr) {
// Simple event handler
})
.on("deleteComplete", function (event, id, xhrOrXdr, isError) {
// Simple event handler
})
;

包括通过 Fiddler 捕获的两个上传处理程序响应,第一个将 success 设置为 false,因为我选择的图像太小;

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-Headers: Content-Type, cache-control, x-requested-with
Access-Control-Allow-Credentials: false
Date: Tue, 17 Mar 2015 12:47:54 GMT
Content-Length: 204

{
"success": false,
"error": "Minimum upload size is 150 KB, \"Winter.jpg\" was 103 KB"
}<script src="//www.example.com/fineuploader-4.2.2/iframe.xss.response.js"></script>

随后 IE 立即获取“waitingPath.gif”和“iframe.xss.response.js”,但我没有看到任何自定义错误文本 - 只是“没有有效消息”错误。

由于图像较大,第二次捕获成功设置为 true,并且我们返回了一些自定义参数,结果与上面相同。

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-Headers: Content-Type, cache-control, x-requested-with
Access-Control-Allow-Credentials: false
Date: Tue, 17 Mar 2015 12:51:18 GMT
Content-Length: 278

{
"pageList": [],
"name": "Winter 2.JPG",
"uuid": "2563",
"size": 281,
"thumbnailUrl": null,
"pageCount": 0,
"success": true,
"newUuid": "2563"
}<script src="//www.example.com/fineuploader-4.2.2/iframe.xss.response.js"></script>

编辑:感谢您的帮助,我的回复要么错误地使用了 UUID,要么完全丢失了它 - 请参阅下面的最终结果。

成功

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-Headers: Content-Type, cache-control, x-requested-with
Access-Control-Allow-Credentials: false
Date: Tue, 17 Mar 2015 15:01:57 GMT
Content-Length: 310

{
"pageList": [],
"name": "Winter 2.JPG",
"newUuid": "2567",
"size": 281,
"thumbnailUrl": null,
"pageCount": 0,
"success": true,
"uuid": "6cb9f309-0c38-4a73-aa13-879abbfff008"
}<script src="//www.example.com/addin/fineuploader-4.2.2/iframe.xss.response.js"></script>

失败

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-Headers: Content-Type, cache-control, x-requested-with
Access-Control-Allow-Credentials: false
Date: Tue, 17 Mar 2015 15:01:43 GMT
Content-Length: 255

{
"success": false,
"uuid": "61a4e504-4b89-4b67-ad38-df23d7c4a247",
"error": "Minimum upload size is 150 KB, \"Winter.jpg\" was 103 KB"
}<script src="//www.example.com/addin/fineuploader-4.2.2/iframe.xss.response.js"></script>

最佳答案

由于缺少 uuid 参数,第一个响应无法正确解析。第二个回应看起来有点奇怪。 “2563”是 Fine Uploader 在请求中发送的 UUID,还是您要分配给文件的新 UUID?响应中的“uuid”和“newUuid”参数具有相同的值。根据您响应的请求,此响应中的 UUID 必须与文件的 UUID 相匹配。

尚不清楚这是否是这里的问题,但如果“uuid”和“newUuid”匹配,则表明您的代码存在问题或您存在误解。

关于javascript - Fine Uploader - 未从加载的 iframe 收到有效消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29100133/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com