我正在使用Ionic 3构建我的移动应用程序,并且必须根据要求下载文件。同样,我需要获取下载文件的响应头信息。我正在使用File Transer插件(https://ionicframework.com/docs/native/file-transfer/)下载文件。
下面是我在做什么。
private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (_user != null)// Check for active logged-on user
{
var senderGrid = (DataGridView)sender;// Cast sender to DataGridView object type
if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)// check column is checkbox column
{
btnGroupAssets.Enabled = true;// Enable group assets button
if (dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor == Color.AliceBlue)
{
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightCoral;
}
else if (dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor == Color.LightCoral)
{
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.AliceBlue;
}
}
}
else
{
MessageBox.Show("Login required");// Prompt user for login
List<Form> forms = new List<Form>();
foreach (Form f in Application.OpenForms)// Check open forms for login form
if (f.Name == "Login" || f.Name == "li")// If there is an instance of login, close it
forms.Add(f);
foreach (Form f in forms)
f.Close();
Login li = new Login();// Open new login form
li.Show();
}
}
使用所需的参数启动下载后,下载成功,并且得到的响应就像
downloadAndOpen(downloadURL, attachmentName) {
let options: FileUploadOptions = {
headers: {'Authentication-Info': localStorage.getItem("SessionID")}
}
var savePath = this.file.dataDirectory + attachmentName;
this.fileTransfer.download(downloadURL, savePath, false, options).then((entry) => {
// Need to get the Header information.
});
}
服务器团队在Response标头中发送的敏感信息很少,这些信息将在下载文档时使用。在Ionic Native File Transfer插件中找不到正确的信息来获取响应头信息。