0
ASP.NETから受信しました:私はモデルファイルを作成しました角度側では解析のバイト配列は、私がsomefileというクラスを作成したコア
public async Task<IActionResult> GetFiles(string guid)
{
return Ok(new SomeFile() { Content = zippedFiles.ToArray(),
Name = $"zippedFiles.zip", MimeType = "application/x-zip-compressed" });
}
:
角度:私は角側でContentプロパティのために使用する必要がありますどのような種類
public downloadZip(): Observable<any> {
return this.http
.get(fooUrl)
.map((response: Response) => <SomeFile> response.json());
};
:
export interface SomeFile {
Content: **Uint8Array** //am I correct to use this type?
MimeType: string
Name: string
}
とHTTPサービスは、次のようにこのオブジェクトを取得しますか? Uint8Array
を正しく使用していますか? 私はエラーが出る原因:
ERROR SyntaxError: Unexpected token P in JSON at position 0
は私が.map((response: Response) => <SomeFile> response.json());
を行うべきではないことができますか?
jsonではバイナリデータを返すことはできません。 JSONに入れる前にbase64でエンコードする必要があります。 – Tseng
@Tsengを意味しますか? 'System.Convert.ToBase64String(image)' – StepUp
@TsengとAngular側の 'Content'プロパティにはどのような型を使用しますか? – StepUp