I'm using Android and I am following this tutorial:
https://github.com/OneDrive/onedrive-picker-android/blob/master/README.md
public void uploadToOneDrive(String content,Context context){
final String filename = "Temp.xml";
final File f = new File(context.getFilesDir(), filename);
try {
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(context.openFileOutput("Temp.xml", Context.MODE_PRIVATE));
outputStreamWriter.write(content);
outputStreamWriter.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
Log.e("Exception", "File write failed: " + e.toString());
}
System.out.println("File " + f.toString());
mSaver = Saver.createSaver(ONEDRIVE_APP_ID);
mSaver.startSaving((Activity)context,filename, Uri.fromFile(f));
}
This is my method that returns ERROR TYPE NoFileSpecified. I am trying to just create a new temporary file, put a string into it and then delete it.
This is how I call it:
oneDriveUpload.getSaver().handleSave(requestCode, resultCode, data);
05-29 15:03:18.649 10649-10649/david.projectclouds I/System.out: File /data/user/0/david.projectclouds/files/Temp.xml
05-29 15:03:18.702 10649-10649/david.projectclouds I/System.out: URI: file:///data/user/0/david.projectclouds/files/Temp.xml
So there is a file and the URI is something that is accepted. I'm lost.
EDIT: I've tried using content content://david.projectclouds.MainActivity/file/diabetix/Temp.xml
But I still have the same error.
There are apparently some issues with Android 7.0 and the SDK. So I just used my own intents.
Intent intentOD = new Intent(Intent.ACTION_SEND);
intentOD.setType("text/*");
intentOD.setPackage("com.microsoft.skydrive");
intentOD.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intentOD.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(getContext(), "david.projectclouds.MainActivity", f));
getContext().startActivity(Intent.createChooser(intentOD, "title"));