2017-11-18 1 views
0

azure blob 트리거를 사용하여 blob 스트림을 JSON 객체로 deserialize하려고합니다. 이 방아쇠는 비디오를 방울 저장소에 업로드 할 때마다 시작됩니다. 그러나,이 오류를 던지고있다 :Azure Blob 스트림을 Json 객체에 역 직렬화합니다.

Newtonsoft.Json: Unexpected character encountered while parsing value: . Path ''.

이것은 내가 역 직렬화하기 위해 사용하고있는 코드입니다 :

public static void Run(Stream myBlob, string name, TraceWriter log) 
{ 
    myBlob.Position = 0; //resetting stream's position to 0 
    var serializer = new JsonSerializer(); 
    using(var sr = new StreamReader(myBlob)) 
    { 
     using(var jsonTextReader = new JsonTextReader(sr)) 
     { 
      BlobData blobData = serializer.Deserialize<BlobData>(jsonTextReader); 
     } 
    } 

    public class BlobData 
    { 
     public string path { get; set; } 
    } 
} 

어떤 도움이 appreciated.Thanks 될 것이다.

+0

질문을 편집하고 BLOB의 실제 내용을 포함 할 수 있습니까? –

+0

앞서 언급했듯이 얼룩에는 비디오가 포함되며 업로드 후에 트리거가 작동합니다. 현재 샘플 비디오를 일부 사용하고 있습니다. – Vin

+1

BLOB가 비디오 일 때 어떻게 JSON 객체로 직렬화 해제 될 수 있습니까? –

답변

0

A i mentioned earlier, the blob will contain a video and after upload a trigger will fire. As of now, i am using some sample videos

Gaurav Mantri는 비디오를 JSON 객체로 역 직렬화 할 수 없다고 언급했습니다. 비디오 BLOB가 업로드 된 후 BLOB Uri를 가져오고 다른 BLOB URL을 다른 데이터 저장소에 저장하려는 경우 내 이해에 따라 당신이 Create and use a SAS with Blob storage에 따라 수,

run.csx

#r "Microsoft.WindowsAzure.Storage" 

using Microsoft.WindowsAzure.Storage.Blob; 

public static void Run(CloudBlockBlob myBlob, string name, TraceWriter log) 
{ 
    //blob has public read access permission 
    var blobData = new BlobData() { path = myBlob.Uri.ToString() }; 

    //blob is private, generate a SAS token for this blob with the limited permission(s) 
    var blobSasToken=myBlob.GetSharedAccessSignature(new SharedAccessBlobPolicy() 
      { 
       SharedAccessExpiryTime =DateTimeOffset.UtcNow.AddDays(2), 
       Permissions = SharedAccessBlobPermissions.Read 
      })); 
    var blobData = new BlobData() 
      { 
      path = $"{myBlob.Uri.ToString()}{blobSasToken}" 
      }; 
    //TODO: 
} 

을 또한 :이 시점에서, 당신은 당신의 myBlob 매개 변수에 대한 CloudBlockBlob 유형을 결합 수 있으며, 다음과 같이 블롭 URL을 검색 할 수 있습니다 더 자세한 코드 샘플은 Azure Functions Blob storage bindings, Get started with Azure Blob storage using .NET입니다.

관련 문제