- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在尝试创建一个带有封面照片的群组 channel ,
this.sendBirdInstance.GroupChannel.createChannelWithUserIds(userIds, true, this.groupName, this.groupPhotoFile, '', function (createdChannel, error) {
...
}
根据文档,我可以添加一个 url 或一个文件
coverUrl : the file or URL of the cover image, which you can fetch to render into the UI.
但是在添加文件时,我总是得到:"SendBirdException", code: 800110, message: "Invalid arguments."
有没有办法用文件而不是 url 创建一个组(因为我希望用户上传文件)?
谢谢,
最佳答案
正如您已经体验过的(几天前我看到您创建了一个 issue in GitHub),SendBird 的支持有点不可靠。
他们提供的事实 just a minified version他们的 JavaScript SDK(我个人觉得它很差)对两者都有帮助。
无论如何,我可以隔离createChannelWithUserIds
函数:
! function (e, n) {
// ...
}(this, function () {
// ...
var h = function (e) {
for (var n in e) if (e.hasOwnProperty(n)) return !1;
return Array.isArray(e) ? JSON.stringify(e) === JSON.stringify([]) : JSON.stringify(e) === JSON.stringify({})
},
// ...
A = function () { // it returns SendBird function
// ...
var w = function (e) { // w is this.GroupChannel
// ...
w.createChannelWithUserIds = function () {
// ...
// here comes the param validation (I've added spaces for a better lecture):
if (!Array.isArray(e) || "boolean" != typeof n || "string" != typeof t && null !== t && void 0 !== t || "string" != typeof r && h(r) && null !== r && void 0 !== r || "string" != typeof a && null !== a && void 0 !== a || "string" != typeof i && null !== i && void 0 !== i) return void U(null, new p("Invalid arguments.", J.INVALID_PARAMETER), s);
// It will return "Invalid arguments." if any of the conditions evaluates to true
// ...
}
}
}
return function () {
// ...
}().SendBird
});
你正在使用这样的功能:
createChannelWithUserIds(o, n, t, r, a, s);
所以第四个参数(r
)就是coverURL
:封面图片的文件(this.groupPhotoFile
);
它的验证基本上是说:
"string" != typeof r // if `r` is not a string (a URL)
&& h(r) // and the returned value of function h(r) is true
&& null !== r // and it is not null
&& void 0 !== r // and it is not undefined
该参数无效。
您的文件不是字符串,不是 null 也不是未定义的,所以一切都归结为 h()
函数:
var h = function (e) {
for (var n in e) if (e.hasOwnProperty(n)) return !1;
return Array.isArray(e) ? JSON.stringify(e) === JSON.stringify([]) : JSON.stringify(e) === JSON.stringify({})
}
上面的函数首先检查对象是否有任何属性是对象本身的成员(即不属于原型(prototype)链的属性)。然后,如果它没有任何自己的属性,它会检查 stringify 对象/数组是否等于空对象/数组。
我不能说开发人员在通过这个函数验证文件时的意图是什么,但是一个标准的 FILE 对象:
true
。true
。如前所述,我们需要 h()
返回 false
:如果返回 true
,则验证失败。
要修复此行为,您可以将 h()
函数更改为如下内容:
var h = function( e ){
return !(e instanceof File);
// or return e.constructor != File;
// or return Object.getPrototypeOf( e ) != File.prototype );
// or return e.__proto__ != File.prototype )
// or return e.constructor.prototype != File.prototype )
}
但我不会惹事的。它可以在未来的版本中用于不同的目的。
所以最好的办法是将 createChannelWithUserIds()
函数更改为:
h()
函数的调用。为此,您可以覆盖 SendBird 实例中的函数:
var sb = new SendBird( { appId: ... } );
sb.GroupChannel.createChannelWithUserIds = function(){ ... };
但它不能保证工作并且可能会在未来的版本中中断,所以我只编辑 SendBird.min.js 文件。换句话说,替换:
if(!Array.isArray(e)||"boolean"!=typeof n||"string"!=typeof t&&null!==t&&void 0!==t||"string"!=typeof r&&h(r)&&null!==r&&void 0!==r||"string"!=typeof a&&null!==a&&void 0!==a||"string"!=typeof i&&null!==i&&void 0!==i)return void U(null,new p("Invalid arguments.",J.INVALID_PARAMETER),s);
与:
if(!Array.isArray(e)||"boolean"!=typeof n||"string"!=typeof t&&null!==t&&void 0!==t||"string"!=typeof a&&null!==a&&void 0!==a||"string"!=typeof i&&null!==i&&void 0!==i)return void U(null,new p("Invalid arguments.",J.INVALID_PARAMETER),s);
在当前版本(v3.0.41)中,您会发现上述代码有两个巧合:一个是createChannel
,另一个是createChannelWithUserIds
,您可以将两者替换。
当然,编辑 .js 文件很烦人,因为每次升级 SendGrid 时都需要注意替换代码。你可以在你的 CI 管道中创建一个自动任务来为你做这件事,我想。
希望 SendGrid 开发人员能够确认您的问题并在未来的版本中修复它。
关于javascript - SendBird 以文件为封面创建 GroupChannel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46036724/
我正在制作游戏并有一系列“房间”图像,这些图像使用 background-size: cover 进行缩放(并在必要时进行裁剪)以适应浏览器窗口。 . 我想将一些游戏内元素放置在这些图像的关键位置之上
我正在尝试构建一个像个人资料/封面布局这样的 facebook,但我正在为正确的布局而苦苦挣扎。 我目前拥有的: http://jsfiddle.net/kvEBF/
我正在尝试全屏拉伸(stretch)图像(封面):http://www.bootply.com/114850 我有一个简单的菜单和一个号召性用语按钮,但图像仅覆盖菜单并停在那里。 部分样式如下。 .s
我正在生成 epub 图书文件,但遇到了一个问题。它不读我的封面。这是 cover.xhtml 我做错了什么吗?关于 epub 创建的 IMB 文档告诉我,我唯一需要的是 cover.html 文件和
我使用了许多覆盖的背景图像。 如果我在页面内容区域和固定的左侧面板内使用相同的图像,它会非常频繁地闪烁。 转载: http://jsfiddle.net/7aUnL/8/ HTML:
我想获取文件的increment id,代码如下: // get increment id func GetID() uint64 { appIdLock.Lock() defer a
您好,我正在尝试让封面照片填满整个页面,但没有修复。我希望这样,一旦您开始滚动封面照片滚动和内容显示。我已将高度参数设置为 900 ish 以适合大多数屏幕,但我正在寻找一种方法让它覆盖所有浏览器/分
每当背景图像发生变化时,我都需要它来覆盖主体。我正在使用 background-size: cover,但它似乎不起作用。 body { position: relative; margi
我正在尝试使用以下方法获取 FB 页面的封面 url: $fql_query_url = "https://graph.facebook.com" ."/$fb_id[id]?fields=c
关于 ipad 和 iphone 的大小以及如何使用不同的 css,我遇到了几种方法和问题。真的有必要吗,尤其是现在 ipad 和 iphone 的版本越来越多,每个设备都有不同的背景? 几乎每个关于
.slide{ background: 50% 50% / cover; } background: 50% 50%/cover 有什么作用? 我知道后台语法是这样的 http://www.w
我正在尝试将多个 div 放置在背景图像之上,以产生很酷的效果。主要问题是网站是响应式的,图像也是如此 - 它是 background-size: cover 这使得在查看更大/更小的屏幕时很难将叠加
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
您好,对于网上商店,我希望产品 block 像书本一样打开。并在 de inside-left 上显示图像(打开时) 我试过这样做。它工作正常,但我希望黑色 div 向左打开。这个将包含图像。当我放一
我正在创建一个不垂直滚动的页面。这是供引用的问题页面 - http://horizonwebtest.zxq.net/knowledgebase/ 除以下两点外,它运行良好: 在 iPad(可能是其他
我希望你能帮助我,我被这个问题困住了。 此处示例:http://myko.dk/pegasus/index.html (进行中) 我想让背景图像自动调整大小以适合浏览器宽度。现在,如您所见,图像在调整
如果有人能帮助我并告诉我如何用 CSS/HTML 制作背景封面,我将不胜感激。 我打算做的是制作一个 100% 宽度和 270 像素高度的封面,这将适合并且不会拉伸(stretch)我的图像,我不介意
今天我发现 Firefox 18.0.2 有一个奇怪的行为。即使更新到 FF19.0 也无济于事。 我需要创建具有动态大小并保持特定纵横比的缩略图。可能还有其他更好的解决方案,如下所示。 Html:
我用过Jcrop广泛,但我想以与 Facebook 用于裁剪其封面图像非常相似的方式裁剪图像。 因此,我希望 div 具有某种固定大小,其中背景保存其原始大小的可拖动图像,用户拖动该图像并找到要裁剪的
我正在从图片选择器中挑选一张图片,然后我想更改该图片作为 Facebook 封面的比例。我有一张图片,假设它的分辨率为 640 宽和 480 高,我想将其更改为 facebook 封面(851 像素宽
我是一名优秀的程序员,十分优秀!