5
votes

I am attempting to use the new Application Data folder in the Drive SDK, but rather than creating a new file as the sample code shows, I wish to create a copy of a template file which the user selects. My template files are Google-editable spreadsheets held within a specific Drive account and are world-readable, with their IDs configured in my application.

I first tried the copy by specifying appdata as a parent ID in the body of the copy request, as follows

{
  "title": "New file",
  "parents": 
  [
    {
      "id": "appdata"
    }
  ]
}

this produced a 403 error with the text

Only folders or files with content stored in Drive are allowed within the appdata folder

So I tried adding root as a second parent in the parents array, as follows

{
  "title": "New file",
  "parents": 
  [
    {
      "id": "appdata"
    },
    {
      "id": "root"
    }
  ]
}

This fails again with a 403, but a slightly different error

Method not supported for appdata contents

I have also tried updating the parents property of the new file after creation, and by inserting a new value into the parents entity of the newly-created file, both of which yield the same 'Method not supported' error.

So my question is, is it possible to create a copy of an existing field held in Drive, within a user's appdata folder? The fact that this consistently fails suggests not and that I may have to use the user's normal storage, but I would like to use the appdata folder if possible to separate my app's content from their general Drive files.

3

3 Answers

2
votes

Actually, unfortunately you cannot currently place a realtime file within the appdata folder. This is something we are looking at adding, but in most cases it doesn't make sense since the content of the appdata folder is restricted to a single user.

Cheryl Simon on Google Drive Developers - https://plus.google.com/communities/107264319205603895037

1
votes

I have come across the same issue.

So, if i create a native document in the appdata folder, i get: "Only folders or files with content stored in Drive are allowed within the appdata folder"

BUT, i can put a non-native document there (e.g. a pdf) and access it (e.g. view it).

What i'm after is to be able to do the same procedure for native documents. The "Only folders or files with content stored in Drive are allowed within the appdata folder" response i get back seems more applicable to shortcut files for example. I wonder if returning that for a native doc is a bug?

1
votes

Ok, thankyou.

Back to the original question: is it possible to move a file to the appdata folder? e.g. by removing all parents, then adding appdata as a parent.

I get the following response: "Method not supported for appdata contents"

Or can files only get in there by inserting?