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);

2 Answers 2

5

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));
Sign up to request clarification or add additional context in comments.

1 Comment

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);

5 Comments

so for my example above, byte[] image/png, should I use Uint32, Float32, Unit8? what is the best option out of 3?
@mattsmith5 actually, it depends on your condition. maybe try out float32.
hi, what condition is that? what should I look out for?
@mattsmith5 based on the data stored in the buffer. AFAIK
its a byte array png, I am trying to research what array type out of the 3 is best for image pngs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.