Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 将xls文件上载到azure data lake gen1时不支持获取文件格式_Angular_Azure Data Lake - Fatal编程技术网

Angular 将xls文件上载到azure data lake gen1时不支持获取文件格式

Angular 将xls文件上载到azure data lake gen1时不支持获取文件格式,angular,azure-data-lake,Angular,Azure Data Lake,我正在开发一个应用程序,它将使用angular7和.net core从用户那里获取文件输入。我使用websocket将负载传递到后端。我能够成功上传到azure datalake,但当我预览或下载文件时,文件会被刷新,并且文件大小也高于原始文件大小 upload.html <input id="file-input" accept=".xlsx" type="file" style="display: none" (change)="addExternalFile($event)" /&

我正在开发一个应用程序,它将使用
angular7
.net core
从用户那里获取文件输入。我使用websocket将负载传递到后端。我能够成功上传到azure datalake
,但当我预览或下载文件时,文件会被刷新,并且文件大小也高于原始文件大小

upload.html

<input id="file-input" accept=".xlsx" type="file" style="display: none"  (change)="addExternalFile($event)" />
之后,我将有效负载传递到websocket,如下所示:

var data = { "fileName": this.FileName, "Path": "", "sheetName": this.Sheetlist, "filetype": this.FileType, "Filedata": this.Filedata };
      var payload = JSON.stringify(data);
       this.commonService.sendMessageToServer(payload);
我的控制器:

 public async Task<string> CreateDataSetFromFile(MessageWrapper wrapper)
        {
            var tenantname = wrapper.TenantName;
            var tenantID = wrapper.TenantID;
            AdlCred adlcred = new AdlCred();
            adlcred._adlsAccountName = "";     
            string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            string fileName = jobject["fileName"].ToString();


            string pathname = "/upload/" + fileName;

            //JObject tempArray = JObject.Parse( jobject["Filedata"].ToString());
            string stringData = jobject["Filedata"].ToString();



            //byte[] Filedata = Encoding.ASCII.GetBytes(jobject["Filedata"].ToString());
            byte[] Filedata =  Encoding.ASCII.GetBytes(jobject["Filedata"].ToString());

           // string[] arrayString = new string[]; //Your Array.

            byte[] arrayByte = new byte[Filedata.Length];

            for (int i = 0; i < arrayByte.Length; i++)
            {
                arrayByte[i] = Convert.ToByte(arrayByte[i]);
            }
            Stream stream = new MemoryStream(arrayByte);

         //   MemoryStream stream = new MemoryStream(Filedata);
            string sname = "Sheet1";
            bool extHeader = true;
            bool hasMerCells = false;


            await Create(stream, pathname, true, adlcred);
}

 public async Task Create(Stream stream, string destFilePath, bool overWridden, AdlCred adlcred)
        {
            try
            {




                //  var creds = ApplicationTokenProvider.LoginSilentAsync(adlcred._domain, adlcred._applicationId, adlcred._secretKey).Result;

                var creds = ApplicationTokenProvider.LoginSilentAsync("", "", "").Result;

                DataLakeStoreFileSystemManagementClient _adlsFileSystemClient = new DataLakeStoreFileSystemManagementClient(creds);



                await _adlsFileSystemClient.FileSystem.CreateAsync("althing", destFilePath, stream,true);
                // _adlsFileSystemClient.FileSystem.Append(adlcred._adlsAccountName, destFilePath, stream);
                //  await _adlsFileSystemClient.FileSystem.CreateAsync(adlcred._adlsAccountName, destFilePath, stream, overWridden);
                Console.WriteLine("File Uploaded Successfully...");
            }
            catch (Exception ex)
            {



            }
        }
公共异步任务CreateDataSetFromFile(MessageWrapper)
{
var tenantname=wrapper.tenantname;
var tenantID=wrapper.tenantID;
AdlCred AdlCred=新的AdlCred();
adlcred._adlsAccountName=“”;
string contentType=“application/vnd.openxmlformats officedocument.spreadsheetml.sheet”;
字符串fileName=jobject[“fileName”].ToString();
字符串路径名=“/upload/”+文件名;
//JObject tempArray=JObject.Parse(JObject[“Filedata”].ToString());
字符串stringData=jobject[“Filedata”].ToString();
//byte[]Filedata=Encoding.ASCII.GetBytes(jobject[“Filedata”].ToString());
byte[]Filedata=Encoding.ASCII.GetBytes(jobject[“Filedata”].ToString());
//string[]arrayString=新字符串[];//您的数组。
字节[]数组字节=新字节[Filedata.Length];
for(int i=0;i
是的,我试图重现相同的场景,但得到了相同的错误

似乎,从门户下载会导致此问题,但如果您的应用程序被卡住,您可以使用Azure storage explorer或AZ cli下载该文件

Azure存储资源管理器:

https://azure.microsoft.com/en-us/features/storage-explorer/
Powershell示例:

https://docs.microsoft.com/en-us/azure/data-lake-store/data-lake-store-get-started-powershell#rename-download-and-delete-data-from-your-data-lake-storage-gen1-account
希望能有帮助

https://docs.microsoft.com/en-us/azure/data-lake-store/data-lake-store-get-started-powershell#rename-download-and-delete-data-from-your-data-lake-storage-gen1-account