René's URL Explorer Experiment


Title: Google Drive Python API: Adding Multiple Properties · Issue #947 · googleapis/google-api-python-client · GitHub

Open Graph Title: Google Drive Python API: Adding Multiple Properties · Issue #947 · googleapis/google-api-python-client

X Title: Google Drive Python API: Adding Multiple Properties · Issue #947 · googleapis/google-api-python-client

Description: Hello, I would like to add multiple entries into the properties metadata field for a file so that the file is indexable using files().list(). Here is my code: # define read and write permissions SCOPES = ['https://www.googleapis.com/auth...

Open Graph Description: Hello, I would like to add multiple entries into the properties metadata field for a file so that the file is indexable using files().list(). Here is my code: # define read and write permissions SC...

X Description: Hello, I would like to add multiple entries into the properties metadata field for a file so that the file is indexable using files().list(). Here is my code: # define read and write permissions SC...

Opengraph URL: https://github.com/googleapis/google-api-python-client/issues/947

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Google Drive Python API: Adding Multiple Properties","articleBody":"Hello,\r\n\r\nI would like to add multiple entries into the `properties` metadata field for a file so that the file is indexable using `files().list()`. Here is my code:\r\n```py\r\n# define read and write permissions\r\n\r\nSCOPES = ['https://www.googleapis.com/auth/drive.file']\r\n\r\n# check if the user's access and refresh tokens already exist\r\n\r\nimport pickle\r\nimport os\r\n\r\nif os.path.exists('token.pickle'):\r\n    with open('token.pickle','rb') as f:\r\n        creds = pickle.load(f)\r\nelse:\r\n    creds = None\r\n\r\n\"\"\"\r\nIf the user's access and refresh tokens don't exist, or they are no longer valid, then create them and save them. This will not work if the credentials.json file is not in the user's working directory.\r\n\"\"\"\r\n\r\nfrom google_auth_oauthlib.flow import InstalledAppFlow\r\nfrom google.auth.transport.requests import Request\r\n\r\nif not creds or not creds.valid:\r\n    if creds and creds.expired and creds.refresh_token:\r\n        creds.refresh(Request())\r\n    else:\r\n        flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)\r\n        creds = flow.run_local_server(port=0)\r\n    \r\n    with open('token.pickle', 'wb') as f:\r\n        pickle.dump(creds,f)\r\n\r\n\"\"\"\r\ncheck that the authentication flow worked. This should be the same as the string in the \"client_id\" field in the credentials.json file. Additionally, if the access and refresh tokens did not already exist, then a token.pickle file should now be in the user's working directory.\r\n\"\"\"\r\n\r\nprint('client_id is: {}'.format(creds.client_id))\r\n\r\n# create a drive object to directly interface with the user's Google Drive.\r\n\r\nfrom googleapiclient.discovery import build\r\n\r\ndrive = build('drive', 'v3',credentials=creds)\r\n\r\n# create a folder in the root directory of the user's Google Drive.\r\n\r\nfolder_metadata = {\r\n    \r\n    'name': 'TestFolder',\r\n    'mimeType': 'application/vnd.google-apps.folder'\r\n    \r\n}\r\n\r\nfolder = drive.files().create(body = folder_metadata, fields = 'id,name').execute()\r\n\r\n# upload a file with indexable properties to the created folder\r\n\r\n# first create the file\r\nwith open('HelloWorld.txt','w') as f:\r\n    f.write('Hello World!')\r\n\r\n# then define metadata\r\nproperty1 = {'key' : 'day_of_week', 'value' : 'Monday'}\r\nproperty2 = {'key' : 'patient_num', 'value' : '001'}\r\n\r\nfile_metadata = {\r\n    'name': 'HelloWorld.txt',\r\n    'parents': [folder['id']],\r\n    'properties':[property1,property2]\r\n}\r\n\r\n# finally upload\r\nfrom googleapiclient.http import MediaFileUpload\r\n\r\nmedia = MediaFileUpload('HelloWorld.txt',chunksize = -1,resumable = False)\r\nfile = drive.files().create(body = file_metadata, media_body = media, fields = 'name,properties').execute()\r\n\r\n# try to search for the file\r\n\r\nquery = \"properties has {key = 'patient_num' and value = '001'}\"\r\n\r\nfiles_list = drive.files().list(q = query, fields = 'files(name,properties)').execute()\r\n\r\n```\r\nWhen I execute this code, `files_list` contains `{'files': []}`. The reason for this is because the `file` variable contains:\r\n```\r\n{'name': 'HelloWorld.txt',\r\n 'properties': {'value': 'Monday', 'key': 'day_of_week'}}\r\n```\r\nClearly, the `'patient_num'` property was not added to the `properties` field, even though it was explicitly defined in the `file_metadata` dictionary. I am aware of this [question](https://stackoverflow.com/questions/19038308/google-drive-file-properties-how-to-set-multiple-properties-in-one-request) on Stack Overflow, but I feel that the proposed solution is inefficient. How do I add multiple properties to a file so that it is indexable using either the `day_of_week` property or the `patient_num` property or both properties at the same time? Also, once I can do this, how should I modify `query` so that I am able to index using multiple properties simultaneously?\r\n\r\nThanks a lot,\r\nMahmoud Abdelkhalek\r\n\r\n","author":{"url":"https://github.com/mhdadk","@type":"Person","name":"mhdadk"},"datePublished":"2020-06-24T16:21:51Z","url":"https://github.com/googleapis/google-api-python-client/issues/947"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:7da6a7ea-dec5-6b9f-bd6a-508dd61af09a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8C7E:35EBD3:1B78D:21175:6B088768
html-safe-nonce27b491025c44cb463cb327f2acaa7b8302fb2a60b70702985eeee532a643c428
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzdFOjM1RUJEMzoxQjc4RDoyMTE3NTo2QjA4ODc2OCIsInZpc2l0b3JfaWQiOiIzNjUzOTIwMjQ0NjM0MjU3MjU2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac367cde4555a89307f99d0e1bf87dc22b3bbec5e9d6208c5df57ec3d9227944d2
hovercard-subject-tagissue:644745243
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-api-python-client/947/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d7fb28b95c73a307323160460137fc0eac40b1c0624cda5711187cff5d712d5a/googleapis/google-api-python-client/issues/947
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d7fb28b95c73a307323160460137fc0eac40b1c0624cda5711187cff5d712d5a/googleapis/google-api-python-client/issues/947
og:image:altHello, I would like to add multiple entries into the properties metadata field for a file so that the file is indexable using files().list(). Here is my code: # define read and write permissions SC...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemhdadk
hostnamegithub.com
expected-hostnamegithub.com
None60e86161f3e246339ce8d4bd308e3da0ecd5ebd5e610d57e00d21487fe085d68
turbo-cache-controlno-preview
go-importgithub.com/googleapis/google-api-python-client git https://github.com/googleapis/google-api-python-client.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id15749269
octolytics-dimension-repository_nwogoogleapis/google-api-python-client
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id15749269
octolytics-dimension-repository_network_root_nwogoogleapis/google-api-python-client
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasee87e2b0f8aff9e45b7ac6c81be5a939ad971830c
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/googleapis/google-api-python-client/issues/947#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgoogle-api-python-client%2Fissues%2F947
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgoogle-api-python-client%2Fissues%2F947
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=googleapis%2Fgoogle-api-python-client
Reloadhttps://github.com/googleapis/google-api-python-client/issues/947
Reloadhttps://github.com/googleapis/google-api-python-client/issues/947
Reloadhttps://github.com/googleapis/google-api-python-client/issues/947
googleapishttps://github.com/googleapis
google-api-python-clienthttps://github.com/googleapis/google-api-python-client
Codehttps://github.com/googleapis/google-api-python-client
Issues17 (17)https://github.com/googleapis/google-api-python-client/issues
Pull requests40 (40)https://github.com/googleapis/google-api-python-client/pulls
Discussionshttps://github.com/googleapis/google-api-python-client/discussions
Actionshttps://github.com/googleapis/google-api-python-client/actions
Projectshttps://github.com/googleapis/google-api-python-client/projects
Security and qualityhttps://github.com/googleapis/google-api-python-client/security
Insightshttps://github.com/googleapis/google-api-python-client/insights
https://github.com/googleapis/google-api-python-client
New issuehttps://github.com/login?return_to=https://github.com/googleapis/google-api-python-client/issues/947
New issuehttps://github.com/login?return_to=https://github.com/googleapis/google-api-python-client/issues/947
Google Drive Python API: Adding Multiple Propertieshttps://github.com/googleapis/google-api-python-client/issues/947#top
https://github.com/busunkim96
api: drivehttps://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22api%3A%20drive%22
type: questionhttps://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22type%3A%20question%22
https://github.com/mhdadk
mhdadkhttps://github.com/mhdadk
on Jun 24, 2020https://github.com/googleapis/google-api-python-client/issues/947#issue-644745243
questionhttps://stackoverflow.com/questions/19038308/google-drive-file-properties-how-to-set-multiple-properties-in-one-request
busunkim96https://github.com/busunkim96
api: drivehttps://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22api%3A%20drive%22
type: questionhttps://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22type%3A%20question%22
on Jun 24, 2020https://github.com/googleapis/google-api-python-client/issues/947#event-3478762616
https://github.com/busunkim96
busunkim96https://github.com/busunkim96
on Jun 24, 2020https://github.com/googleapis/google-api-python-client/issues/947#issuecomment-648993705
@mhdadkhttps://github.com/mhdadk
https://github.com/mhdadk
mhdadkhttps://github.com/mhdadk
on Jun 24, 2020https://github.com/googleapis/google-api-python-client/issues/947#issuecomment-649089972
@busunkim96https://github.com/busunkim96
https://github.com/busunkim96
busunkim96https://github.com/busunkim96
on Jun 24, 2020https://github.com/googleapis/google-api-python-client/issues/947#issuecomment-649104928
http://googleapis.github.io/google-api-python-client/docs/dyn/drive_v3.files.html#createhttp://googleapis.github.io/google-api-python-client/docs/dyn/drive_v3.files.html#create
https://github.com/googleapis/google-api-python-client/blob/master/docs/dyn/index.mdhttps://github.com/googleapis/google-api-python-client/blob/master/docs/dyn/index.md
propertieshttps://developers.google.com/drive/api/v3/ref-search-terms#operators
https://developers.google.com/drive/api/v3/reference/fileshttps://developers.google.com/drive/api/v3/reference/files
https://github.com/mhdadk
mhdadkhttps://github.com/mhdadk
on Jun 24, 2020https://github.com/googleapis/google-api-python-client/issues/947#issuecomment-649114479
@busunkim96https://github.com/busunkim96
thishttps://developers.google.com/drive/api/v3/ref-search-terms#file_properties
thishttps://stackoverflow.com/a/26286007
thishttps://github.com/googleapis/google-api-nodejs-client/issues/426#issuecomment-245205480
https://github.com/busunkim96
busunkim96https://github.com/busunkim96
on Jun 24, 2020https://github.com/googleapis/google-api-python-client/issues/947#issuecomment-649118670
https://developers.google.com/drive/api/v3/supporthttps://developers.google.com/drive/api/v3/support
https://stackoverflow.com/questions/tagged/google-drive-apihttps://stackoverflow.com/questions/tagged/google-drive-api
busunkim96https://github.com/busunkim96
completedhttps://github.com/googleapis/google-api-python-client/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 24, 2020https://github.com/googleapis/google-api-python-client/issues/947#event-3479703027
https://github.com/mhdadk
mhdadkhttps://github.com/mhdadk
on Jun 25, 2020https://github.com/googleapis/google-api-python-client/issues/947#issuecomment-649735514
https://github.com/busunkim96
busunkim96https://github.com/busunkim96
on Jun 25, 2020https://github.com/googleapis/google-api-python-client/issues/947#issuecomment-649748955
@mhdadkhttps://github.com/mhdadk
JustinBeckwithhttps://github.com/JustinBeckwith
busunkim96https://github.com/busunkim96
on Feb 2, 2021https://github.com/googleapis/google-api-python-client/issues/947#event-4276868358
Sign up for freehttps://github.com/signup?return_to=https://github.com/googleapis/google-api-python-client/issues/947
Sign in to commenthttps://github.com/login?return_to=https://github.com/googleapis/google-api-python-client/issues/947
busunkim96https://github.com/busunkim96
api: drivehttps://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22api%3A%20drive%22
type: questionhttps://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22type%3A%20question%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.