ios - meteor 应用程序 : Difference Between Uploading Images from Iphone than Computer?

标签 ios iphone image mobile meteor

我有一个实时运行的 meteor 应用程序,我测试了在桌面上上传图像,它们工作正常。但是当我尝试使用 iPhone 的 Safari 浏览器时,它崩溃并重新加载页面。

如果您从手机上传图片,设置之间有什么不同吗?我正在使用 Collection FS。请注意,这不是 IOS 应用程序,而是从移动浏览器上传的。

相关代码如下

    HTML

<div class="fileUpload btn btn-success btn-lg  pull-right visible-xs visible-sm">
  <span class=""><i class="fa fa-camera"></i></span>
  <input type="file" class="myFileInput" accept="image/*" />
</div>


CLIENT SIDE 

 'change .myFileInput': function(event, template) {
    var user = Meteor.user();
    var files = event.target.files;
    var fsFile = new FS.File(files[0]);
    fsFile.username = user.username;

    var newImage = Images.insert(fsFile, function(err, response, fileObj) {
      if (err) {
        console.log(err)
      } else {
        console.log('success');
      }
    });

  }




  SERVER SIDE 

  var profileThumbsStore = new FS.Store.S3('thumb', {
    accessKeyId: Meteor.settings.key,
    secretAccessKey: Meteor.settings.secret,
    bucket: Meteor.settings.bucket,
    folder: 'thumb',
    transformWrite: function(fileObj, readStream, writeStream) {
      gm(readStream, fileObj.name()).resize("100", "100").stream().pipe(writeStream);
    }
  });


  var profileStore = new FS.Store.S3('original', {
    accessKeyId: Meteor.settings.key,
    secretAccessKey: Meteor.settings.secret,
    bucket: Meteor.settings.bucket,
    folder: 'original',
    transformWrite: function(fileObj, readStream, writeStream) {
      gm(readStream, fileObj.name()).resize("500", "500").stream().pipe(writeStream);
    }
  });

  Images = new FS.Collection('images', {
    stores: [profileStore, profileThumbsStore],
    filter: {
    // maxSize: 1048576, // in bytes
    allow: {
      contentTypes: ['image/*'],
    },
    onInvalid: function (message) {
      if (Meteor.isClient) {
        sAlert.error(message);
      } else {
        sAlert.success(message);
      }
    }
  }
  });

正如我提到的,它在桌面上工作正常,所以我不明白为什么它不能在 iphone 上工作。

如有任何帮助,我们将不胜感激。

最佳答案

尝试使用 FS.Utility - 我在移动设备和浏览器上使用它,它运行得非常好!

'change .myFileInput': function(event, template) {
  var user = Meteor.user();
  FS.Utility.eachFile(ev, function(file){
    file.username = user.username;
    var newImage = Images.insert(file, function(err, response, fileObj) {
      if (err) {
        console.log(err)
      } else {
        console.log('success');
      }
    });
  }
}

关于ios - meteor 应用程序 : Difference Between Uploading Images from Iphone than Computer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31973950/

相关文章:

ios - 从自定义 View 的连接检查器中隐藏 socket

objective-c - SubstringWithRange NSString 内存泄漏

iphone - 更新导航栏

iphone - 出现 'Assignment makes integer from pointer without cast' 错误

Python OpenCV : inverting colors in a numpy image array

html - 对齐图片下方和旁边的文本

ios - iOS 中简单的对象拖动

ios - 移除导航栏和工具栏的边框

iphone - 加载前 View 已删除

image - 连接组件标记算法在某些情况下会失败