waynehoover / s3_direct_upload

Direct Upload to Amazon S3 With CORS
MIT License
651 stars 333 forks source link

empty type when uploading xls file #224

Open MrHubble opened 9 years ago

MrHubble commented 9 years ago

When I attempt to upload a xls file the file is uploaded correctly (I have checked on S3 and it's there) but it returns with an empty ("") filetype whereas the other uploads (xlxs, pdf, jpg, etc) return with a filetype value.

I have tried adding custom code but it doesn't change the value of data:

#s3_direct_upload.js.coffee
  setUploadForm = ->
    $uploadForm.find("input[type='file']").fileupload

      add: (e, data) ->
        file = data.files[0]
        file.unique_id = Math.random().toString(36).substr(2,16)

        fileType = ""
        if ("type" of file) && (file.type != "")
          fileType = file.type
        else
          ext = file.name.split('.').pop()
          if ext == "xls"
            fileType = "application/vnd.ms-excel"
        data.files[0].type = fileType

I've added similar code as above to formData which results in the correct name: "content-type" being sent to S3 but an empty type is still returned in my s3_uploads_complete event. As a workaround (in my complete event) I use similar code as above to set the correct type in my hidden form value so the correct values are submitted with the form.

My workaround is working for me at the moment but it would be great if someone could shed some light as to where I might be going wrong.

murilloflores commented 8 years ago

I'm facing the same issue right now. Have you found any solution other than changing your complete event?

MrHubble commented 8 years ago

No, I'm still using the same workaround. Please report back if you find another solution.

vishnur-github commented 7 years ago

Any update on this guys ?