title: How to create a thumbnail image out of a file uploaded in cloudinary in Scala
body: <p>Can someone please help me with some code for creating a thumbnail for any file(csv, xlsx, docx, pdf, etc) in Scala. I am uploading the file in the cloudinary and using cloudinary we can create thumbnail images as per the link: <a href="https://cloudinary.com/blog/how_to_generate_thumbnails_for_office_documents_using_cloudinary_and_aspose" rel="nofollow noreferrer">https://cloudinary.com/blog/how_to_generate_thumbnails_for_office_documents_using_cloudinary_and_aspose</a>
  But, I am not able to understand how to achieve the same in Scala. Below is my code of uploading the file.</p>
  
  <pre><code>request.body.asMultipartFormData.map { multipartFormData =&gt;
              multipartFormData.file("file").map { file =&gt;
                val companyId = cachedUser.companyId
                val splitFile = file.filename.split("\\.")
                val fileExtension = splitFile(splitFile.length - 1)
                if (!notAllowedFileExt.contains(fileExtension)) {
                  val fileName = UserUtil.md5(cachedUser.userId + "&amp;" + user.name + /*"&amp;" + user.rememberToken +*/ "&amp;" + scala.util.Random.nextInt) + "." + fileExtension
                  //val fileName = "userpic" + cachedUser.userId + "." + fileExtension
                  Logger.info(request.remoteAddress + " : " + cachedUser.userId + " --&gt; uploaded file " + filesUploadPath + "/" + fileName)
                  val fileLoc = new File(filesUploadPath + "/" + fileName)
                  file.ref.moveTo(fileLoc, replace = true)
                  val cloudFileName = "rewards_and_recognition/attachments/"+companyId + "/userfile"+ unixTimestamp + cachedUser.userId /**** Cloudinary File Name ****/
                  val (cloudinaryAttachmentUrl, publicId, url) = Await.result(CloudinaryUpload.imageUpload(cloudFileName, fileLoc.getAbsolutePath, file.contentType), Duration(40, "second"))
  
                  if(cloudinaryAttachmentUrl != ""){
                    Ok(Json.obj("status_message" -&gt; "File uploaded", "filename" -&gt; file.filename, "cloud_attachment" -&gt; url, "public_id" -&gt; publicId))
                  } else
                    NotFound(Json.obj("err" -&gt; "Cloudinary upload failed!"))
                } else {
                  BadRequest(Json.obj("err" -&gt; "Invalid File Format!"))
                }
              }.getOrElse(BadRequest(Json.obj("err" -&gt; "Please select a file and press upload button")))
            }.getOrElse(NotFound(Json.obj("err" -&gt; "MultipartFormData not found")))
  </code></pre>