I've created a SomeFile class:
C#:
public class SomeFile
{
public byte[] Content { get; set; }
public string MimeType { get; set; }
public string Name { get; set; }
}
and this file is returned in a such way:
public async Task<IActionResult> GetFiles(string guid)
{
return Ok(new SomeFile() { Content = zippedFiles.ToArray(),
Name = $"zippedFiles.zip", MimeType = "application/x-zip-compressed" });
}
At Angular side I've created model file:
Angular:
export interface SomeFile {
Content: **Uint8Array** //am I correct to use this type?
MimeType: string
Name: string
}
and http service gets this object like this:
public downloadZip(): Observable<any> {
return this.http
.get(fooUrl)
.map((response: Response) => <SomeFile> response.json());
};
What type should I use for Content property at Angular side?
Am I correct to use Uint8Array?
Cause I get the error:
ERROR SyntaxError: Unexpected token P in JSON at position 0
May be I should not do .map((response: Response) => <SomeFile> response.json());?
System.Convert.ToBase64String(image)Contentproperty at Angular side?