You are on page 1of 5

Spring Boot Pagination and Sorting

Choose Form Data as Body Type which allows us to choose file

1. Create SB project - Web dependency

2. Configuring Server and File Storage Properties

## MULTIPART (MultipartProperties)

# Enable multipart uploads

spring.servlet.multipart.enabled=true

# Threshold after which files are written to disk.

spring.servlet.multipart.file-size-threshold=2KB

# Max file size.

spring.servlet.multipart.max-file-size=200MB

# Max Request Size

spring.servlet.multipart.max-request-size=215MB

## File Storage Properties

# All files uploaded through the REST API will be stored in this directory

file.upload-dir=/Users/callicoder/uploads

3. Writing APIs for File Upload and Download

Use Select Files to choose file(s)


We can have other Parameters as well

Enabling GZip compression in Spring Boot


GZip compression is a very simple and effective way to save bandwidth
and improve the speed of your website.

It reduces the response time of your website by compressing the


resources and then sending it over to the clients. It saves bandwidth by
at least 50%.

GZip compression is disabled by default in Spring Boot. To enable it,


add the following properties to your  application.properties  file -

# Enable response compression

server.compression.enabled=true

# The comma-separated list of mime types that should be


compressed
server.compression.mime-types=text/html,text/xml,text/
plain,text/css,text/javascript,application/
javascript,application/json

# Compress the response only if the response size is at


least 1KB

server.compression.min-response-size=1024

Note that, GZip compression has a small overhead. Therefore I’ve


added a  min-response-size  property to tell spring boot server to
compress the response only if the size is more than the given value.

IF we look back at our download example In


the developer tools-> network we can
see that there is no encoding present.

Now, lets enable compression

we can see that there is gzip encoding present.


Wildcards in mime-type are not supported
The compression, spring boot relies on support provided by
underlying embedded servers. Unfortunately, these servers do not provide any
consistent wildcards support in mime-type.

Jetty is doing strict string comparisons, but it also allows configuring a


whitelist/blacklist for this. [Link]

 Tomcat is checking that the response content-type starts with one of


the configured mimetypes. So
configuring application/vnd.company would work for
both application/vnd.company.v3+json and application/vnd.company
.v2+xml. [Link]
Drop me your questions related to Gzip compression in spring boot.

You might also like