Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JGraph
>
Tutorial
> Upload file - replace the contents of an existing file
Replace the contents of an existing file.
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import com.independentsoft.graph.GraphClient; import com.independentsoft.graph.GraphException; import com.independentsoft.graph.files.DriveId; import com.independentsoft.graph.files.DriveItem; public class Console { public static void main(String[] args) { try { GraphClient client = new GraphClient(); client.setClientId("63333333-209e-454e-b7bd-55a4d201270f"); client.setTenant("independentsoft.onmicrosoft.com"); client.setClientSecret("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); try (FileInputStream fileStream = new FileInputStream("e:\\Test.pdf")) { DriveItem item = client.uploadDriveItem("/Folder1/Test.pdf", new DriveId("b!T7ZW_FMzJ02x_G6HteZHZ"), fileStream); System.out.println("Id: " + item.getId()); System.out.println("WebUrl: " + item.getWebUrl()); } } catch (GraphException e) { System.out.println(e.getCode()); System.out.println(e.getMessage()); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*