简体   繁体   English

将录音上传到ftp

[英]upload audio recording to ftp

I need to upload audio files recorded from my application .I am unable to upload aac files to ftp. 我需要上传从我的应用程序录制的音频文件。我无法将aac文件上传到ftp。 Here is my code to upload 这是我要上传的代码

FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(myftppath);

                ftp.Credentials = new NetworkCredential(username,password);

                ftp.UseBinary = true;
                ftp.Method = WebRequestMethods.Ftp.UploadFile;

                FileStream fs = File.OpenRead(audioFilePath);

                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, buffer.Length);

                fs.Close();

                Stream ftpstream = ftp.GetRequestStream();
                ftpstream.Write(buffer, 0, buffer.Length);
                ftpstream.Close();
                ftpstream.Flush();

The code works for uploading other files like txt,png,mp3 etc but not for aac files. 该代码适用于上传其他文件,如txt,png,mp3等,但不适用于aac文件。 Please help 请帮忙

Your code seems to be correct. 你的代码似乎是正确的。 You may try this, 你可以试试这个,

  1. If you are running the app on simulator,check if your OS has permission to write file to ftp. 如果您在模拟器上运行应用程序,请检查您的操作系统是否有权将文件写入ftp。
  2. Install your app on real device and try to upload using the same code. 在真实设备上安装您的应用并尝试使用相同的代码上传。

If none works then find out the exact cause of error using try block. 如果没有工作,那么使用try块找出错误的确切原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM