1

I am able to upload a spreadsheet (.csv or XLS files), but when checking on the file from Parse.com, it is all empty. I am uploading the file from client side code (not using REST). Do you think that is the problem? This works just fine for a simple image/file upload using a similar code, but fails for csv or xls type file. Here's the code:

$scope.uploadSpFile = function(fileUpload){
      var name = fileUpload.name; 
      var parseFile = new Parse.File(name, fileUpload.spFile);
      var serverUrl = 'https://api.parse.com/1/files/' + fileUpload.name;
      var mySpreadsheet = new Parse.Object(fileUpload.className);         
      $.ajax({
          type: "POST",
          beforeSend: function(request) {
            request.setRequestHeader("X-Parse-Application-Id", parse_app_id);
            request.setRequestHeader("X-Parse-REST-API-Key", parse_rest_id);
            request.setRequestHeader("Content-Type", fileUpload.spFile.type);
          },
          url: serverUrl,
          data: fileUpload.mySpreadsheet,
          processData: false,
          contentType: false,
          success: function(data) {
            mySpreadsheet.set({filetitle: data.name});
            mySpreadsheet.set({fileurl: data.url});
            mySpreadsheet.set({name: name});
            mySpreadsheet.set({fileCategory: ''});
            mySpreadsheet.set({file: {"name": data.name,"url": data.url,"__type": "File"}});
            mySpreadsheet.save();
            console.log('file saved!');
          },
          error: function(data) {
            var obj = jQuery.parseJSON(data);
            console.log('error: ' + obj.error);
            outputMsg = obj.error;
          }
        });
      }
    });

when i use a similar code to upload an image, I can access the file on my parse page, but xls or csv files turn out to be empty (actually, in XLS case, an error pops out as the format is corrupted). Anyone has any idea how to fix this issue? thanks for the help.

2
  • I changed the "__type" from "File" to fileUpload.spFile.type on the file's URI, but still the same problem. Commented Jan 6, 2015 at 1:54
  • Is anyone out there to help me with this issue?? I am still stuck :-( Commented Jan 9, 2015 at 2:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.