Bonjour à tous je souhaite upload des fichiers via l'API DropBox sachant que j'utilise Spring (spring security aussi) mais j'obtiens l'erreur suivante :

Etat HTTP 405 - Request method 'POST' not supported

Pouvez-vous me guider s'il vous plaît, je ne comprends pas ce qu'il ne va pas...

Ma méthode dans le controller:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
 
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
    public void uploadFile(@RequestParam("file") File file) throws IOException, DbxException{
        final String APP_KEY = "MON CODE";
        final String APP_SECRET = "MON CODE";
 
        DbxAppInfo appInfo = new DbxAppInfo(APP_KEY, APP_SECRET);
 
        DbxRequestConfig config = new DbxRequestConfig(
                "syndic/1.0", Locale.getDefault().toString());
        DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(config, appInfo);
 
        String authorizeUrl = webAuth.start();
        System.out.println("1. Go to: " + authorizeUrl);
        System.out.println("2. Click \"Allow\" (you might have to log in first)");
        System.out.println("3. Copy the authorization code.");
 
        String code = new BufferedReader(new InputStreamReader(System.in)).readLine().trim();
 
        // This will fail if the user enters an invalid authorization code.
        DbxAuthFinish authFinish = webAuth.finish(code);
        String accessToken = authFinish.accessToken;
 
        DbxClient client = new DbxClient(config, accessToken);
        System.out.println("Linked account: " + client.getAccountInfo().displayName);
 
        File inputFile = file;
        FileInputStream inputStream = new FileInputStream(inputFile);
        try {
            DbxEntry.File uploadedFile = client.uploadFile("/magnum-opus.txt",
                    DbxWriteMode.add(), inputFile.length(), inputStream);
            System.out.println("Uploaded: " + uploadedFile.toString());
        } finally {
            inputStream.close();
        }
    }
Mon formulaire dans la JSP:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
<body>
 
<div class="container">
 
 
    <form:form method="POST" enctype="multipart/form-data">
 
        <form:errors path="*" cssClass="errorblock" element="div" />
 
        Please select a file to upload : <input type="file" name="file" />
        <input type="submit" value="upload" />
		<span><form:errors path="file" cssClass="error" />
		</span>
 
    </form:form>
 
</div>
 
</body>