I have implemented a SomeFile class:
C#:
public class SomeFile
{
public byte[] Content { get; set; }
public string MimeType { get; set; }
public string Name { get; set; }
}
and the file is retrieved in the following manner:
public async Task<IActionResult> GetFiles(string guid)
{
return Ok(new SomeFile() { Content = zippedFiles.ToArray(),
Name = $"zippedFiles.zip", MimeType = "application/x-zip-compressed" });
}
On the Angular side, I have created a model file:
Angular:
export interface SomeFile {
Content: **Uint8Array** //is it correct to use this type?
MimeType: string
Name: string
}
and the http service receives this object like so:
public downloadZip(): Observable<any> {
return this.http
.get(fooUrl)
.map((response: Response) => <SomeFile> response.json());
};
What type should be used for the Content property on the Angular side?
Is it correct to use Uint8Array
?
Because I am encountering the error:
ERROR SyntaxError: Unexpected token P in JSON at position 0
Maybe I shouldn't use
.map((response: Response) => <SomeFile> response.json());
?