संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
यहां दिए गए उदाहरण में, किसी नोट और उसके अटैचमेंट को वापस पाने का तरीका बताया गया है:
REST
अटैचमेंट डाउनलोड करने के नाम और alt=media यूआरएल पैरामीटर के साथ, media.download() को कॉल करें.
alt=media यूआरएल पैरामीटर, सर्वर को बताता है कि कॉन्टेंट डाउनलोड करने का अनुरोध किया जा रहा है.
/** * Gets and downloads the attachment of a note. * * @param note The note whose attachment will be downloaded. * @throws IOException */privatevoidgetNoteAttachment(Notenote)throwsIOException{// First call is to get the attachment resources on the note.List<Attachment>attachments=keepService.notes().get(note.getName()).execute().getAttachments();if(!attachments.isEmpty()){Attachmentattachment=attachments.get(0);StringmimeType=attachment.getMimeType().get(0);// A second call is required in order to download the attachment with the specified mimeType.OutputStreamoutputStream=newFileOutputStream("attachmentFile."+mimeType.split("/")[1]);keepService.media().download(attachment.getName()).setMimeType(mimeType).executeMediaAndDownloadTo(outputStream);}}
[null,null,["आखिरी बार 2025-03-11 (UTC) को अपडेट किया गया."],[],[],null,["# Retrieve notes and attachments\n\nThe following sample shows how to retrieve a note and its attachment: \n\n### REST\n\nCall\n[`media.download()`](/workspace/keep/api/reference/rest/v1/media/download)\nwith the name of the attachment download and the `alt=media` URL parameter.\nThe `alt=media` URL parameter tells the server that a download of content is\nbeing requested.\n\nTo get the name of the attachment, you must first [retrieve the note](#note).\n| **Note:** The `alt=media` URL parameter is a [system parameter](https://cloud.google.com/apis/docs/system-parameters) available across all Google REST APIs. If you use a client library for the Google Keep API, you do not need to explicitly set this parameter.\n\n### Java\n\n /**\n * Gets and downloads the attachment of a note.\n *\n * @param note The note whose attachment will be downloaded.\n * @throws IOException\n */\n private void getNoteAttachment(Note note) throws IOException {\n // First call is to get the attachment resources on the note.\n List\u003cAttachment\u003e attachments =\n keepService.notes().get(note.getName()).execute().getAttachments();\n\n if (!attachments.isEmpty()) {\n Attachment attachment = attachments.get(0);\n String mimeType = attachment.getMimeType().get(0);\n // A second call is required in order to download the attachment with the specified mimeType.\n OutputStream outputStream = new FileOutputStream(\"attachmentFile.\" + mimeType.split(\"/\")[1]);\n keepService\n .media()\n .download(attachment.getName())\n .setMimeType(mimeType)\n .executeMediaAndDownloadTo(outputStream);\n }\n }"]]