Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you send simple byte array through POST method #192

Open
manodupont opened this issue Sep 30, 2020 · 2 comments
Open

How do you send simple byte array through POST method #192

manodupont opened this issue Sep 30, 2020 · 2 comments

Comments

@manodupont
Copy link

manodupont commented Sep 30, 2020

I just want to send a byte array that would correspond to the curl method as is

curl --location --request POST 'myurl' \
--header 'Authorization: Bearer {{TOKEN}}' \
--header 'Content-Type: image/jpeg' \
--data-binary '@/Users/myfile/location.jpg'

I tried so many things ..... nothing seems to work.

The further i went is this

@POST
    @Path("{bucketName}/o")
    @Consumes("image/jpeg")
    @Produces(MediaType.APPLICATION_JSON)
    GCPUploadResponseDto upload(@HeaderParam(HttpHeaders.AUTHORIZATION) String bearerToken,
                                @HeaderParam(HttpHeaders.CONTENT_TYPE) String contentType,
                                @PathParam String bucketName,
                                @QueryParam("uploadType") String uploadType,
                                @QueryParam("name") String filename,
                                byte[] data);

A little background: Im using this to upload to GCP Storage. Good news is : I do have an entry created on GCP but with 0 bytes.

It seems like the Content-Length stays at 0.

I tried many things related to the byte array that i sent. Trying with some annotations like @RequestBody, i also tried with some OutputStream, nothings seems to fix the thing.

A lot of time it happens to return also this error
Caused by: org.apache.http.ProtocolException: Content-Length header already present

And on top of that, it seems like i can't find anything on google related to Microprofile byte array.

Is this feasible in the end ?!

Thanks.

Im running on Quarkus, with this lib : microprofile-rest-client-api-1.4.1.jar

Thank you.

@Emily-Jiang
Copy link
Member

@manodupont since this is related to Quarkus, I suggest you ask this on Quarkus mailinglist.

@manodupont
Copy link
Author

Well, thanks for the advise.

Although, i would like to get some information around sending binary data with MicroProfile Rest client ?!

Is there any doc related to that ? I can't find anything except multiform data part, but what about simple body with data byte array.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants