Search code examples
javascriptc#fine-uploader

Having trouble getting FineUploader's Initial File List feature working


I've spent too much time on this feature already. I've read the documentation, I've searched Stackoverflow. The problem I'm having is that I always get success = false and of course no files are loaded. Documentation says if it has a problem parsing any item in the response but I'm at a loss as to what I'm doing wrong.

Here is what my server returns in response to the Inital Files request:

{{
    "uuid": "3377cc66-51d2-4e80-a695-f9018e379b7b",
    "path": "~/UploadedFiles/6f633f07-b23a-43f1-8256-f0dfe9fc9abb",
    "originalFilename": "Cut Offs.png",
    "name": "636785647541018142.png",
    "size": null,
    "thumbnailUrl": null
}}

On the client side I am able to retrieve each of these properties just fine. Thinking that perhaps it was choking on something else I reduced it down to just the uuid and the name as those are the only ones required but I got the same result. It didn't work and the success parameter comes in as false.

The sessionRequestComplete is firing off just fine but success is always false.

Here is what I have on the server:

public FineUploaderResult GetFiles(string type)
{
    List<FormDocument> documents = (List<FormDocument>) Session["IVRFiles"];

    JObject json = new JObject();

    if ( documents != null && documents.Count > 0 )
    {
        string jsonString = JsonConvert.SerializeObject(documents);

        jsonString = jsonString.TrimStart(new char[] { '[' }).TrimEnd(new char[] { ']' });
        json = JObject.Parse(jsonString);
    }
    return new FineUploaderResult(true, json);

}

Am I not returning the proper thing? Here's the constructor for FineUploader Result in case that helps.

public FineUploaderResult(bool success, object otherData = null, string error = null, bool? preventRetry = null)
{
    _success = success;
    _error = error;
    _preventRetry = preventRetry;

    if (otherData != null)
        _otherData = JObject.FromObject(otherData);
}

Any help would be most appreciated.


Solution

  • Got it figured out. What I was returning wasn't what I should have been. I was using that FineUploaderResult class but I don't believe I should have been. So I replaced all that json string and serialize and convert stuff to something far more simple and it worked. Here's what I have on the server now:

    public ActionResult GetFiles(string type)
    {
        List<FormDocument> documents = (List<FormDocument>) Session["IVRFiles"];
    
        return Json(documents, JsonRequestBehavior.AllowGet);
    }
    

    And this works just fine.