Parse: Cannot Upload File
I want to make an app which have upload file function. But the problem is, I unable to find where did I do wrong. First, choose the file public void onClick(View arg0) {
Solution 1:
it should be like this
Uriuri= data.getData();
// get path
filePath = uri.getPath();
// get file name
String fileNameSegments[] = filePath.split("/");
fileName = fileNameSegments[fileNameSegments.length - 1];
// convert it to bytebyte[] fileByte = fileName.getBytes();
// Create the ParseFileParseFilefile=newParseFile(fileName, fileByte);
// Upload the file into Parse Cloud
file.saveInBackground();
// Create a New Class called "FileUpload" in ParseParseObjectfileUpload=newParseObject("FileUpload");
// Create a column named "FileName" and set the string
fileUpload.put("FileName", fileName);
Log.d(TAG, "image file");
// Create a column named "ImageFile" and insert the image
fileUpload.put("DocFile", file);
// Create the class and the columns
fileUpload.saveInBackground();
Log.d(TAG, "toast");
// Show a simple toast message
Toast.makeText(MainActivity.this, "File Uploaded",
Toast.LENGTH_SHORT).show();
though the class not created in parse dashboard but I guess that need another post.
Post a Comment for "Parse: Cannot Upload File"