There's nothing related to file upload in the examples under https://github.com/ExpediaGroup/graphql-kotlin/tree/master/examples/server/spring-server/src/main/kotlin/com/expediagroup/graphql/examples/server/spring.
I'd like to upload 5 files at once and although I think it should be a mutation I'm not sure whether it should go like this:
class UploadMutation: Mutation {
fun upload(files: FilePart) {
print("$files")
}
}
The context is obviously Spring Boot with Kotlin and WebFlux.
According to the developers they don't support Apollo-like file uploads at all.
File uploads can be built using our library and spring boot, but they are not included out of the box. You will have to configure the response parser yourself
https://github.com/ExpediaGroup/graphql-kotlin/discussions/1037
Related
This is a really simple question, but hard to find the answer.
I'm using kotlin DSL and gradle (so build.gradle.kts and settings.gradle.kts).
I'm using netflix-dgs and spring boot like so:
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter")
And of course a few others (e.g. extended scalars).
I've figured out how to edit my generateJava task:
tasks.withType<com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask> {
schemaPaths = mutableListOf("$projectDir/src/main/resources/schema")
packageName = "envoy.roomba.netflix.dgs.generated"
}
How do I edit the rest of the configuration mentioned here? https://netflix.github.io/dgs/configuration/.
I tried a gradle.properties file, I've looked briefly at extending #DgsAutoConfiguration, but without any luck.
you can configure properties in the applciation.yml file or application.properties whatever is relevant in your case. Since you are using spring boot, DGS will pick up properties from your application properties file.
I'm working on a Spring Boot project, where some static contents are served from the src/main/resources/static directory.
My goal is that whenever a user tries to access static contents that end with a certain suffix (e.g. ".xlsx"), the request is intercepted and I check to see if the user has the right permission using Spring AOP, and reject the request if necessary. I've got the AOP part working in other scenarios, but not in this scenario yet.
Currently I've tried something like the following, but the method isn't being invoked upon accessing a file of ".xlsx" suffix:
#RequestMapping("/*.xlsx")
public void checkPermission() {
}
Can this be done without using Spring Security? Thanks in advance.
Have you tried Filter interface? much more available.
LINK: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/filter/OncePerRequestFilter.html
Using this you can easily parse the request before even it reaches the controller and add you business logic/validation to it.
i have been strugling since 4 days but did not found the solution for how to bind the url in Spring Boot with gradle.
I have a url as, http://loalhost:8080/blog/post.html?pid=2&ptitle=abc
I want this url to be shown as below with html and (?),
http://localhost:8080/blog/post/2/abc
Is there any way to do that. I don't want to use tucky urlrewriter. All my html files are placed in webapp folder.
Thanks in Advance.
if your have a POST method in your #RestController to create a post blog:
#PostMapping("/blog/post/{pid}/{ptitle}")
public void create(#PathVariable("pid") String pid, #PathVariable("ptitle") String ptitle) {
// a repo save call
}
(I supposed that you use last spring boot version)
Angular newbie here.
In my angular project I need to deliver a file upload feature.
I am using PrimeNg FileUpload since it looks easy to use. I am able to make it work by specifying the necessary attributes provided in the PrimeNG tutorial.
Problem is I am using Angular 2 along with Spring MVC and rest API.
Although I am able to upload files the function is purely on the client side. I am not able to pass the file objects to my spring controller and be able to manipulate it from there.
Could anyone please tell me how to pass the uploaded files from PrimeNg file upload to my spring controller? Thank you in advance :D :)
The client-side implementation of the file-upload is irrelevant, the server just sees a multipart/form-data request.
We're using this approach:
#RequestMapping(value = "/your/path",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
#ResponseStatus(HttpStatus.CREATED)
public YourResponseRepresentation uploadContent(#RequestParam("file") MultipartFile file) {
// You can now access the file's input stream, file name, ...
}
See org.springframework.web.multipart.MultipartFile for details on what's available to use (part op Spring MVC). We're using the Apache Commons FileUpload implementation to do the heavy lifting of the multipart under the hood and offer you a simple stream to read from.
Just add the appropriate commons-fileupload version as dependency and you're ready to go...
I know that there's a tool that is able to do an online validation:
http://online.swagger.io/validator?url=http://petstore.swagger.io/v2/swagger.json
I'm writing a JUnit test that validates the project's swagger.json file. It's important that this validation can be done offline, because the test runs as localhost, and that validation tool can't reach a localhost server.
So, is it possible to validate a Swagger 2.0 JSON file, offline?
I'm very satisfied with this Validator from Atlassian: https://bitbucket.org/atlassian/swagger-request-validator
There is still active development, so I guess they will also provide something for OpenAPI 3.
I have created a Maven project that validates swagger JSON documents if you ever decide to use Maven for running your tests.
You can clone the project here: https://github.com/navidsh/maven.swagger.validator
Well, I finished a Swagger validator using fge/json-schema-validator and Jackson. It uses the Swagger 2.0 schema to validate.
https://gist.github.com/mariosotil/e1219d4e946c643fe0e5
#Singleton
public class SwaggerValidator {
public ArrayNode validate(JsonNode jsonNode) {
return Optional.of(jsonNode)
.map(this::validateWithinSwaggerSchema)
.map(this::getMessagesAsJsonArray)
.get();
}
// [...]
}