0

I am converting this to a Typescript Service for our React web application. Below is the Original API in Java. What is the Typescript Response data type? Blob?

@GET
@Path("/{vendorId}/Photo}")
@Produces("image/png")
byte[] getVendorPhoto(@PathVariable long vendorId);
mattsmith5
  • 540
  • 4
  • 29
  • 67

2 Answers2

2

The JS equivalent of Java byte type is a Int8Array. Because the Java byte is a signed 8-bit integer.

const byteArray = new Int8Array(new ArrayBuffer(arrayOfInts));
Poul Kruijt
  • 69,713
  • 12
  • 145
  • 149
  • follow up question here, https://stackoverflow.com/questions/74480265/react-image-createobjecturl-link-gives-error-404-not-found – mattsmith5 Nov 17 '22 at 18:17
1

By typed array

const idView = new Uint32Array(buffer, 0, 1);
const usernameView = new Uint8Array(buffer, 4, 16);
const amountDueView = new Float32Array(buffer, 20, 1);
Shawn
  • 146
  • 7