且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Ionic - 将文件上传到FTP服务器

更新时间:2022-01-28 09:08:52

如果您的服务器需要HTTP基本身份验证,我可以想到两个选项:

If your server requires HTTP Basic Authentication, there are two options I can think of:


  1. 将凭证放在网址 ftp:// username:password @ url

  2. 直接设置自定义标题 options.headers = {'Authorization':base64('username'+':'+'password')}; li>
  1. Put the credentials in the url ftp://username:password@url
  2. directly set a custom header options.headers = {'Authorization': base64('username' + ':' + 'password') };

请注意,base64必须是一个编码如下所示凭证的函数:

Note that base64 must be a function that encodes the credentials like this:

base64= function(credentials) {
    var hash = btoa(credentials);
    return "Basic " + hash;
};