Invia feedback
Recuperare note e allegati
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
L'esempio seguente mostra come recuperare una nota e il relativo allegato:
REST Chiama media.download()
con il
nome del download dell'allegato e parametro URL alt=media
. La
Il parametro URL alt=media
indica al server che il download di contenuti
richiesta.
Per recuperare il nome dell'allegato, devi prima recuperare la nota .
Nota: il parametro URL alt=media
è un
parametro di sistema
disponibili in tutte le API REST Google. Se utilizzi una libreria client per
API Google Keep, non è necessario impostare esplicitamente questo parametro.
Java
/**
* Gets and downloads the attachment of a note .
*
* @ param note The note whose attachment will be downloaded .
* @ throws IOException
*/
private void getNoteAttachment ( Note note ) throws IOException {
// First call is to get the attachment resources on the note .
List<Attachment> attachments =
keepService . notes () . get ( note . getName ()) . execute () . getAttachments ();
if ( ! attachments . isEmpty ()) {
Attachment attachment = attachments . get ( 0 );
String mimeType = attachment . getMimeType () . get ( 0 );
// A second call is required in order to download the attachment with the specified mimeType .
OutputStream outputStream = new FileOutputStream ( "attachmentFile . " + mimeType . split ( "/ ")[ 1 ]);
keepService
. media ()
. download ( attachment . getName ())
. setMimeType ( mimeType )
. executeMediaAndDownloadTo ( outputStream );
}
}
Invia feedback
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0 , mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0 . Per ulteriori dettagli, consulta le norme del sito di Google Developers . Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2024-08-20 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Mancano le informazioni di cui ho bisogno"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Troppo complicato/troppi passaggi"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Obsoleti"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Problema di traduzione"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Problema relativo a esempi/codice"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Altra"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Facile da capire"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Il problema è stato risolto"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Altra"
}]
Vuoi dirci altro?
{
"last_modified": "Ultimo aggiornamento 2024-08-20 UTC.",
"state": ""
}