小编Ves*_*lis的帖子

Cordova 3.4 FileReader无法正常工作(没有onloadend)

我正在将一个应用程序从phonegap 2.*更新到cordova 3.4现在运行顺畅,只有文件下载不起作用.

我需要从Internet(主机编辑)下载文件并将其存储为JSON文件,以便稍后处理内容.下载工作正常,文件将显示在文件系统中,但FileReader不会触发onloadend事件.

我试图像一些事情onprogressonerror事件,也file.toURIFileReader.readAsDataURL-毫无效果.有人有什么想法吗?

笔记:

  • app.log 可以看作是别名 console.log
  • print_r 在另一个文件中定义,工作正常
  • 下载的文件只有几KB,不应该是性能问题
  • 在iOS硬件上运行

完整代码(提取和缩短):

var fileTransfer = new FileTransfer();

var loadingStatus = 0;
fileTransfer.onprogress = function (progressEvent) {

    // if we have the complete length we can calculate the percentage, otherwise just count up
    if (progressEvent.lengthComputable) {
        loadingStatus = Math.floor(progressEvent.loaded / progressEvent.total * 100);
    } else {
        loadingStatus++;
    }
    app.log('Transfer Progress: ' + loadingStatus);

};

fileTransfer.download(
    encodeURI('http://www.example.com/export'),
    'cdvfile://localhost/persistent/import.json',
    function (file) …
Run Code Online (Sandbox Code Playgroud)

javascript filereader ios cordova

6
推荐指数
1
解决办法
4738
查看次数

Mailgun发送带附件的邮件

我正在尝试使用mailgun发送带附件的邮件.邮件本身很好,但它缺少附件.同样在mailgun日志中,它显示正常,但附件数组为空.

我用example.com替换了我的凭证.该文件放在子目录中并且可读.

$filename = 'directory/example.pdf';
$parameters = array('from' => 'Example <example@mail.example.com>',
                    'to' => 'example@example.com',
                    'subject' => 'Subject',
                    'text' => 'This is just a test.',
                    'attachment[1]' => '@' . $filename);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v3/mail.example.com/messages');
curl_setopt($ch, CURLOPT_USERPWD, 'api:key-ThisIsJustARandomString');

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
Run Code Online (Sandbox Code Playgroud)

我没有收到错误,这是$response:

string(103) "{
    "id": "<20170514122638.8820.55203.4543B111@mail.example.com>",
    "message": "Queued. Thank you."
}"
Run Code Online (Sandbox Code Playgroud)

在mailgun日志中没有列出附件:

"message": {
    "headers": {
        "to": "example@example.com",
        "message-id": "20170514122638.8820.55203.4543B111@mail.example.com",
        "from": "Example <example@mail.example.com>",
        "subject": "Subject" …
Run Code Online (Sandbox Code Playgroud)

php curl attachment mailgun

4
推荐指数
1
解决办法
7044
查看次数

标签 统计

attachment ×1

cordova ×1

curl ×1

filereader ×1

ios ×1

javascript ×1

mailgun ×1

php ×1