【问题标题】:sending file to aws with angular使用角度将文件发送到aws
【发布时间】:2016-04-12 11:42:08
【问题描述】:

我正在尝试将文件发送到 aws 服务器。我正在使用有角的dropzone。我想知道如何发送文件。我有我的 aws 凭据,但不确定如何提出请求。

当我将文件放入 dropzone 时,我会不断收到 'POST https://url.com/ 400(错误请求)'

  angular.extend($scope, {
      dropzoneConfig: {
        'options': {
          'url':'https://url.com',
        },

        'eventHandlers': {
          'sending': function(file, formData, xhr) {
              console.log('sending');
          },
          'success': function(file, response) {
            console.log('sent');
          },
          'error': function() {
            console.log('error');
            $scope.hideDropzone = true;
          }
        }
      }
    });

【问题讨论】:

    标签: javascript angularjs dropzone.js


    【解决方案1】:

    这是非常困难的。 简而言之:

    1. 使用 fileReader 对象读取文件。
    2. 从亚马逊服务器获取预签名 URL。 (使用 PHP 或其他服务器端脚本)
    3. 将 PUT 请求发送到带有编码文件缓冲区内容的预签名 url。
    4. 如果 put 请求成功,向用户显示一些消息。

    我们为实施工作了一个月。

    【讨论】:

      猜你喜欢
      • 2016-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多