0
привет, я пытаюсь загрузить файл в мой резервный отдых api..but, я не могу добиться хорошего результата. Кажется, я не могу прочитать файл. Что не так с кодом?Загрузка файла андроида без ссылки
ошибочный ответ на LogCat
02-25 21:03:02.138 31815-31815/com.bloxofcode.backendless I/Error: Server reported an error - cannot read the file.
вот пример кода ..
public void OnClick_Upload(View v) {
// create a file locally so there is something to upload
String filename = "myhelloworld-async.txt";
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream(filename);
fileOutputStream.write("Hello mbaas!\nUploading files is easy!".getBytes());
fileOutputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
final File file = new File(filename);
Log.i("FileStream",file.getPath());
// now upload the file
backend.Files.upload(file, "/media", new AsyncCallback<BackendlessFile>()
{
@Override
public void handleResponse(BackendlessFile uploadedFile)
{
Log.i("Output","File has been uploaded. File URL is - " + uploadedFile.getFileURL());
//System.out.println("File has been uploaded. File URL is - " + uploadedFile.getFileURL());
//file.delete();
}
@Override
public void handleFault(BackendlessFault backendlessFault)
{
Log.i("Error","Server reported an error - " + backendlessFault.getMessage());
//System.out.println("Server reported an error - " + backendlessFault.getMessage());
}
});
}
Вы можете прочитать файл с помощью Javas FileInputStream? – schaffe