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

base64 of file as a JSON input #2258

Open
glb-cblin opened this issue Dec 18, 2023 · 4 comments
Open

base64 of file as a JSON input #2258

glb-cblin opened this issue Dec 18, 2023 · 4 comments
Labels
enhancement New feature or request topic: generators

Comments

@glb-cblin
Copy link

Problem to solve

I'd like to upload the base64 of a file in one of the parameter of the body

# Upload picture
POST {{PUBLIC_URL}}/public-picture-api/my-pictures
Authorization: Bearer {{id_token}}
{
  "file": "//TODO",
  "fileType": "JPEG",
  "title": "{{title}}",
  "tags": ["{{tag}}"] 
}

At the moment, i must put the whole JSON body in a file ...

@glb-cblin glb-cblin added the enhancement New feature or request label Dec 18, 2023
@jcamiel
Copy link
Collaborator

jcamiel commented Dec 18, 2023

Hi @glb-cblin

Currently, there is no way to inject data in a Hurl file appart from variable.

Like with filter, we're going to introduced generators that will allow this usecase:

# Upload picture
POST {{PUBLIC_URL}}/public-picture-api/my-pictures
Authorization: Bearer {{id_token}}
{
  "file": {{ file "/tmp/foo.bin" base64Encode }},
  "fileType": "JPEG",
  "title": "{{title}}",
  "tags": ["{{tag}}"] 
}

(The syntax is still to be defined).
In this file file "foo.bin" is a generatord, followed by a filter base64dec

See also #2145

@glb-cblin
Copy link
Author

Hi @jcamiel

I've seen #2145 but I thought it was just for Asserts and Captures

Glad to know it will also be usable in bodies !

@glb-cblin
Copy link
Author

Hi @jcamiel

As you closed the related issue, I was testing that on my use case

It does not seem to work

when using "file": {{ file "pic.jpg" base64Encode }}, I have an error ^ expecting '}}' for the "

when using "file": {{ file pic.jpg base64Encode }}, I have an error ^^^^ you must set the variable file for the file keyword

Am I doing something wrong ?

hurl 4.3.0 (Windows) libcurl/8.4.0-DEV Schannel zlib/1.3 nghttp2/1.58.0
Features (libcurl):  alt-svc AsynchDNS HSTS HTTP2 IPv6 Largefile libz NTLM SPNEGO SSL SSPI Unicode UnixSockets
Features (built-in): brotli

@jcamiel
Copy link
Collaborator

jcamiel commented Jun 27, 2024

Hi @glb-cblin the generators feature is still not implemented, the closed issue was a try to have a meta "issue" for grouping relating issues. We've now switch to grouping related issue with labels beginning with "topic:" for instance, topic: generators

I'll update #2302 with a warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic: generators
Projects
None yet
Development

No branches or pull requests

2 participants