小编use*_*915的帖子

将大文件上传到azure blob

我正在使用以下程序将大文件上传到azure blob存储.上传小于500KB的小文件时,程序运行正常,否则我在以下行中收到错误:

blob.PutBlock(blockIdBase64,stream,null);
as" Microsoft.WindowsAzure.Storage.dll中发生类型'Microsoft.WindowsAzure.Storage.StorageException'的未处理异常附加信息:远程服务器返回错误:(400)错误请求. "

没有关于异常的细节,所以我不确定这个问题是什么.关于以下程序中可能出现的错误,是否有任何建议:

class Program
    {

    static void Main(string[] args)
    {
    string accountName = "newstg";
    string accountKey = "fFB86xx5jbCj1A3dC41HtuIZwvDwLnXg==";
    // list of all uploaded block ids. need for commiting them at the end
    var blockIdList = new List<string>();
    StorageCredentials creds = new StorageCredentials(accountName, accountKey);
    CloudStorageAccount storageAccount = new CloudStorageAccount(creds, useHttps: true);
    CloudBlobClient client = storageAccount.CreateCloudBlobClient();
    ?
    ?
    CloudBlobContainer sampleContainer = client.GetContainerReference("newcontainer2");
    string fileName = @"C:\sample.pptx";
    CloudBlockBlob blob = sampleContainer.GetBlockBlobReference("APictureFile6");

    using (var file = new FileStream(fileName, FileMode.Open, …
Run Code Online (Sandbox Code Playgroud)

.net c# azure azure-storage-blobs c#-4.0

1
推荐指数
1
解决办法
1258
查看次数

打字稿中的$是什么意思

我正在使用 Typescript 学习 Angular 2。我遇到了一个让我很困惑的例子。来了

组件.ts

getValidation(state:any, thingName?: string) {  
  let thing: string = state.path || thingName;   
  let messages : string[] = [];   
  messages.push(`You must enter a **${thing}**`);    
}
Run Code Online (Sandbox Code Playgroud)

在上面的例子中使用$and有什么意义{},直到现在我总是使用this.thing来使用任何变量?

typescript angular

1
推荐指数
1
解决办法
1341
查看次数

加入两个列表,LINQ中没有任何匹配的列

我有两个独立的db列表:

List<Id> lstId 哪个有价值 0,1,2,…

List<name> lstnaname 哪个有价值 “a”,”b”,c”

我想结合这两个没有任何共同列的列表.我的预期产量是

List<output> out 
Out[0] = {0,”a”}
Out[1] = {1,”b”}
Run Code Online (Sandbox Code Playgroud)

我尝试在linq中使用concat,但它只是将listA添加到listB中.

Join子句不起作用,因为没有公共字段.我怎么做到这一点?

.net c# linq c#-4.0

0
推荐指数
1
解决办法
352
查看次数

异步方法的返回类型

我在C#中有一个异步方法,如下所示:

public async Task<string> GetData(int id)
        {
        Task<string> inp =  CommonMethod(id);
        return inp;
}

  public async Task<string> CommonMethod(int id)
        {
        string output ;
        output = await service.GetSomeDummyData(id);
        return output;
}
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息,因为“由于这是一个异步方法,所以返回表达式必须是字符串类型,而不是'Task'类型

所以,我将返回类型转换为:

public async Task<string> GetData(int id)
        {
        Task<string> inp =  CommonMethod(id);
        return inp.ToString();
}
Run Code Online (Sandbox Code Playgroud)

该代码已成功编译。

我是异步编程的新手,以上转换方法是返回字符串的最佳实践吗?因为我是从CommonMethod中收集返回类型的Task<string>,而在下一条语句中,我正在使用inp.Tostring()。使用正确的返回类型有点困难。

.net c# asynchronous c#-4.0

0
推荐指数
1
解决办法
3428
查看次数

在jquery中访问data-*

我有一个格式如下:

<div data-role="page" data-last-value="43" data-hidden="true" 

data-bind='attr : {"name":"John"}'></div>
Run Code Online (Sandbox Code Playgroud)

我想把名字从" John "改为" Johnny ".我试图这样做:

$(document).ready(function() {
    alert($( "div" ).data( "options"));

});
Run Code Online (Sandbox Code Playgroud)

这输出我:

attr : {"name" : "John"}
Run Code Online (Sandbox Code Playgroud)

我尝试访问考虑它像json格式, alert($( "div" ).data( "options").attr)但是它是undefined.

它是否为字符串格式,我应该将其设置为某个变量,使用正则表达式并更改字符串格式?如何使用jquery更改它?

html javascript jquery html5

0
推荐指数
1
解决办法
55
查看次数

重构代码并开发干净的代码

我有一个dto如下:

public class DaysDetails
{
 public bool Sun {get;set;}
 public bool Mon {get;set;}
 ...
 public bool Sat {get;set;} //All 7 days of the week
}
Run Code Online (Sandbox Code Playgroud)

我有一个方法,它检查是否检查了日期并构建逗号分隔的字符串格式.例如:如果检查星期日和星期一,则输出为"0,1"(对应于天数的数字)

pubic string ConstructDays(DaysDetails d)
{
 StringBuilder constructDays = new StringBuilder();
 if(d.Sun == true)
  { 
    constructDays.Append("0");
  }
 if(d.Mon == true)
 {
   constructDays.Append("1");
  }
 ..... //So on for all seven days
 string day = Convert.toString(constructDays);

 if(day != string.Empty && day[0] == ",")
   day = day.Remove(0,1);
 return day;
}
Run Code Online (Sandbox Code Playgroud)

我需要将此函数转换为更易于维护的代码和简化版本.这有什么可以改进的?

.net c# asp.net c#-4.0

0
推荐指数
1
解决办法
81
查看次数

HDInsight - Azure blob存储

我对azure hdInsight有一些基本的澄清.以下文章提供了有关使用hdinsight的一些基本输入. https://azure.microsoft.com/en-in/documentation/articles/hdinsight-hadoop-emulator-get-started/.

它说HDinsight内部使用azure blob存储.考虑到这一点,我的问题如下:

我有一个使用存储帐户stg1的hdinsight hd1.如果我想使用azure存储资源管理器上传和下载文件到stg1,那么使用hd1是什么,我甚至可以在没有创建成本高昂的hdinsight的情况下完成它.那么,hadoop hdinsight是否仅用于处理存储在stg1中的一些数据以产生像wordcount这样的结果?这是我们使用HDInsight的唯一原因吗?

azure azure-storage hadoop-streaming hdinsight cortana-intelligence

-1
推荐指数
1
解决办法
242
查看次数