OneDrive metadata hack

Arne-Per HeurbergArne-Per Heurberg ✭✭✭✭
edited May 8, 2020 in Questions
Sorry about the deluge of OneDrive questions.

In the current docs:

"Warning
There is no Download Link metadata for folders; no file (or folder) will download for folder records. To determine whether a record represents a file or a folder, include the size field. Folders display as Size = 0. "
However when I connect, the folders do in fact have sizes greater than zero.


Is there a new technique for this? My client doesn't put "." in folders so we can cheat for a bit but not a long term solution.

Thanks!
AP



Comments

  • Cody TaylorCody Taylor ✭✭✭
    edited May 11, 2020
    Hey Arne-Per!

    Thanks for keeping our docs honest. It looks like that size = 0 trick works for some folders, but definitely not all! I saw the behavior you noted in tests on my own OneDrive instance.

    I'm updating our docs to reflect that the metadata we currently surface doesn't allow for differentiating around folders/files declaratively, and I'll raise this issue with our product management team to see if we can incorporate a solution at some point.

    Thanks again.

  • Arne-Per HeurbergArne-Per Heurberg ✭✭✭✭
    edited May 8, 2020
    I hope you are well Cody. Thanks for the update. In case we return to One Drive (we went to Google Drive for now) did you find a work around to differentiate? I don't mind coding it :). Thanks again!
  • Cody TaylorCody Taylor ✭✭✭
    edited May 11, 2020
    Ooooh, code you say? Well, if you insist... (He says taking off his documentation hat.)

    So OneDrive seems to return different metadata for files versus folders. Rows for folders will have the folder key, while file rows will have the file key.

    This is hackery, but you could probably use a snippet like this that filters your data like a condition: 
    const model = skuid.model.getModel('modelId');
    const filterTo = "folder";
    let rowsToAbandon = [];
    model.getRows().forEach((row)=>{
      if ( !row[filterTo] ){(rowsToAbandon.push(row))}
    });
    model.abandonRows(rowsToAbandon);

    This snippet builds an array of rows to abandon if they do not contain the filterTo key. After going through each row, it then abandons all that do not match. If you run this snippet after any query model actions, it could work. Maybe. Probably. I tested this in like 10 minutes with my small set of OneDrive files.

    Again, this is hackery and could break. No warranty or support is implied haha
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!