Content-type not set when uploading file to Azure Storage

Advertisement

anders.jornehag@sodra.com
Joined:
Posts:
3
Location:
Sweden

Content-type not set when uploading file to Azure Storage

Hi,

We use WinSCP to upload files to an SFTP-enabled Azure Storage Account.
We then use BizTalk to further process the file, but the BizTalk-adapter we use to get the file from the storage require the Content-Type to be set.

When we upload the file using WinSCP, this property is not set. I have tried different transfer modes, but it doesn't make any difference.

I also tried to upgrade to 6.3.3 and I have tried to look in the documentation with no success. Do you have any idea how to solve this?

Best regards,
Anders

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Content-type not set when uploading file to Azure Storage

There's no Content-Type involved in SFTP protocol.
If you want to set the Content-Type, you have to use a different interface.

Reply with quote

anders.jornehag@sodra.com
Joined:
Posts:
3
Location:
Sweden

Thanks for your answer Martin!
As I understand, the Azure Storage SFTP interface defaults content-type to application/octet-stream, and earlier the files we uploaded using WinSCP got the default-content-type but not anymore.

I wrote a C# console app using the Renci.SshNet-package, and when uploading files through this app, the content type was set to the default content type.

Attaching images of blob-properties using WinSCP and Renci.
using Renci.SshNet;
using System;
 
var host = "xxx.blob.core.windows.net";
var port = 22;
var username = "xxxx";
var password = "yyyy";
using var client = new SftpClient(host, port, username, password);
client.Connect();
 
var filePath = @"C:\file.xml";
 
FileStream fs = new(filePath, FileMode.Open);
 
client.UploadFile(fs, $"{Path.GetFileName(filePath)}");

contries_renci_ssh.JPG

contries_winscp.JPG

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Thanks. After some tests, it seems that the SSH_FXP_SETSTAT SFTP request clears the content type on Azure. It seems like a bug in Azure SFTP.

WinSCP uses that request to update the timestamp and/or permissions of the uploaded file.
So either something has changed on Azure side recently, or you had the "Preserve timestamp" (and "Set permissions") turned off before and now you have either of them on.
https://winscp.net/eng/docs/ui_transfer_custom

Turn both off. Or talk to Azure support.

Reply with quote

Advertisement

You can post new topics in this forum