1. Clone the repository
git clone https://github.com/UbaidurRehman1/spring-boot-file-upload-download-rest-api-example.git
2. Specify the file uploads directory
Open src/main/resources/application.properties
file and change the property file.upload-dir
to the path where you want the uploaded files to be stored.
file.upload-dir=/tmp
2. Run the app using maven
cd spring-boot-file-upload-download-rest-api-example
mvn spring-boot:run
- trigger ngrok with your subdomain by
ngrok http -subdomain=${subdomain} 8909
- cURL command to upload file:
curl --location --request POST 'http://${subdomain}.ngrok.io/uploadFile' --form 'file=@"path/to/file"'
- You can download file by:
curl ${fileDownloadUri} -o ${fileName}
where we can getfileDownloadUri
andfileName
from #2 command response