package com.royalrangers.controller;

import com.dropbox.core.DbxException;
import com.dropbox.core.DbxRequestConfig;
import com.dropbox.core.v2.DbxClientV2;
import com.dropbox.core.v2.files.FileMetadata;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.util.Locale;

@RestController
@Slf4j
public class DropboxController {

    @Value("${dropbox.appName}")
    private String appName;
    @Value("${dropbox.accessToken}")
    private String accessToken;

    @PostMapping("/upload")
    public String fileUpload(@RequestParam("file") MultipartFile file) throws IOException, DbxException {
         String UPLOADED_FOLDER = "C://Users//Public//Pictures//Sample Pictures//";

        DbxRequestConfig config = new DbxRequestConfig(appName, Locale.getDefault().toString());
        DbxClientV2 client = new DbxClientV2(config, accessToken);
        if (file.isEmpty()) {
            return "Please select a file to upload";
        }
        InputStream in = new FileInputStream(UPLOADED_FOLDER + file.getOriginalFilename());
        FileMetadata metadata = client.files().uploadBuilder("/" + file.getOriginalFilename())
                .uploadAndFinish(in);

        return "You successfully uploaded '" + file.getOriginalFilename() + "'";
    }
}

@@ -338,17 +338,151 @@
 otation.
-*
+PostMapping;%0Aimport org.springframework.web.bind.annotation.RequestParam;%0Aimport org.springframework.web.bind.annotation.RestController
 ;%0Aimport
@@ -901,92 +901,8 @@
 on %7B
-%0A         String UPLOADED_FOLDER = %22C://Users//Public//Pictures//Sample Pictures//%22;
 %0A%0A  
@@ -1063,16 +1063,17 @@
 Token);%0A
+%0A
         
@@ -1157,16 +1157,56 @@
       %7D%0A
+        byte%5B%5D bytes = file.getBytes();%0A
         
@@ -1226,20 +1226,25 @@
 n = new 
-File
+ByteArray
 InputStr
@@ -1251,52 +1251,13 @@
 eam(
-UPLOADED_FOLDER + file.getOriginalFilename()
+bytes
 );%0A 

Update DropboxController