代码之家  ›  专栏  ›  技术社区  ›  Sergio Reis

如何在节点中使用vimeo upload。js?

  •  0
  • Sergio Reis  · 技术社区  · 7 年前

    我将在Node/Express中将视频上传到我的vimeo应用程序。 我在谷歌上搜索了一下,找到了将视频上传到vimeo的软件包,这就是vimeo上传。

    但我不知道如何使用它。 其格式如下所示。

    var uploader = new VimeoUpload({
        file: file,
        token: accessToken,
    });
    
    uploader.upload();
    

    我在我的项目中得到了accesstoken,并认为文件是视频的二进制文件。

    问题是从视频中获取二进制文件。

    请帮帮我!

    1 回复  |  直到 7 年前
        1
  •  0
  •   Sergio Reis    7 年前

    我发现了vimeo上传的问题。升级了js作为vimeo的API版本。

    vimeo upload中的函数upload()。js,url更改如下。

    me.prototype.upload = function() {
        var xhr = new XMLHttpRequest()
        xhr.open(this.httpMethod, this.url, true)
        xhr.setRequestHeader('Authorization', 'Bearer ' + this.token)
        xhr.setRequestHeader('Content-Type', 'application/json')
    
        xhr.onload = function(e) {
            // get vimeo upload  url, user (for available quote), ticket id and complete url
            if (e.target.status < 400) {
                var response = JSON.parse(e.target.responseText)
                this.url = response.upload.upload_link
                this.user = response.user
                this.ticket_id = response.ticket_id
                this.complete_url = defaults.api_url + response.complete_uri
                this.sendFile_()
            } else {
                this.onUploadError_(e)
            }
        }.bind(this)
    
        xhr.onerror = this.onUploadError_.bind(this)
        xhr.send(JSON.stringify({
            type: 'streaming',
            upgrade_to_1080: this.upgrade_to_1080
        }))
    }