kikovalle / PLGSharepointRestAPI-java

Easy to use wrapper for the Sharepoint Rest API v1. Even if this is not a full implementation it covers most common use cases and provides examples to extending this API.
MIT License
42 stars 32 forks source link

How to filename when uploading #32

Closed DarioJahnel closed 3 years ago

DarioJahnel commented 3 years ago

Hi! first of all thank you for this library, super easy to use!

How can I can I set the filename I upload? I tried doing this (sharepoint site is in spanish)

JSONObject payload = new JSONObject();
payload.put("Nombre", nombreArchivo);
payload.put("nombre", nombreArchivo);
payload.put("name", nombreArchivo);
payload.put("Name", nombreArchivo);
JSONObject result = wrapper.uploadFile(spSiteUrl + spFolder + spBackupFolder, archivo, payload);

but it always uploads the file as "null" image image

DarioJahnel commented 3 years ago

Ok I figured it out

payload.put("FileLeafRef", fileName);

kikovalle commented 3 years ago

This method was added to fix that problem: /**

Where fileName is the final name of the upload file.