Mimetype vs AppID

后端 未结 3 1431
囚心锁ツ
囚心锁ツ 2021-01-24 21:57

You see that it is adivsed to create your file with your app-specific mime type. Is it right way? I wonder because google drive somehow associates files with the application tha

相关标签:
3条回答
  • 2021-01-24 22:30

    FYI-- You mentioned your project ID being alpine-dogfish-833. If you login to the developer console, then click on your project (which takes you to the project "Overview" page), you will see 2 identifiers at the top: Project ID: alpine-dogfish-833 and Project Number: 1088706429537. "Project Number" == "App ID" == "the numeric prefix on the Client ID"

    0 讨论(0)
  • 2021-01-24 22:36

    If the file has custom contents that only your app can understand, use the app specific mime type. Otherwise, use the standard mime type for whatever kind of file you are working with.

    0 讨论(0)
  • 2021-01-24 22:51

    I have finally discovered that when your app (identified with CLIENT_ID) creates a file with mime-type application/vnd.google-apps.drive-sdk, the mime-type is expanded with .<AppID>. The AppID is the first part of your CLIENT_ID. Basically, project ID looked like alpine-dogfish-833 in mine case. I have then generated Client_ID 1088706429537-4oqhqr7o826ditbok23sll1rund1jim1.apps.googleusercontent.com and 1088706429537 is the AppID that we are looking for because when my app creates a file, using

    gapi.client.drive.files.insert({
                  'resource': {
                    mimeType: application/vnd.google-apps.drive-sdk,
                    title: file_name
                  }
    

    Note mime-type is application/vnd.google-apps.drive-sdk -- it does not contain any app ID. Querying the file reveals that the effective mime type of resulting file is actually application/vnd.google-apps.drive-sdk.1088706429537. Google can even fix the mime type even if you misspel application/vnd.google-apps.drive-sdk a bit.

    This answers my question because eliminates all the confusions. The major confusion is that your project has additional application id, that you get even before the CLIENT-ID but it has nothing to do with signing the files with app-specific mime-type. I did not find that in the referred q&a. Secondly, this answers my question because it basically says that mime-type contains APP_ID so that app id and mime-type is therefore the same thing and there is no difference/redundancy/conflict to choose between two.

    0 讨论(0)
提交回复
热议问题