- Mvetsetsani zomwe metadata Drive imayang'anira (dzina, ma tag, indexableText, ndi thumbnails) ndi metadata yomwe ili muzinthu zina za Google Cloud.
- Gwiritsani ntchito Drive API kufunsa ndi kusintha metadata; yeretsani EXIF ndi data yophatikizidwa musanayike mafayilo.
- Lemekezani malire ndi malamulo (tizithunzi, zolemba, zowonjezera) ndikutsimikizirani ndi gcloud pakuyesa kwa REST kwanuko.
Kodi mukufuna kuwongolera metadata yamafayilo anu mu Drive Google ndipo sindikudziwa kuti tiyambire pati? Apa tikufotokoza mwatsatanetsatane, Momwe mungachotsere metadata mu Google Drive moyenera komanso mosamala (metadata ya mafayilo omwe adakwezedwa). Timakuuzaninso malire omwe Google imayika pa mayina a mafayilo, kukula kwake, ndi zilolezo.
Bukuli likupatsani chidziwitso chokwanira komanso chenicheni cha zomwe zingatheke (ndipo zomwe sizingachotsedwe) zikafika pa metadata mu Google Drive.
Zomwe zingasinthidwe kapena "kuchotsedwa" mu Drive
Izi ndizo metadata zomwe zitha kuchotsedwa pamafayilo omwe adakwezedwa ku Google Drive:
Dzina ndi kukulitsa: Popanga fayilo kudzera pa API, ndi bwino kufotokozera kufalikira kwa dzina lachidziwitso, mwachitsanzo, "cat.jpg." Kuyendetsa kumatha kutengera kukulitsa kuchokera ku mtundu wa MIME ngati simunatchule, koma ndi bwino kudzifotokozera nokha. M'mayankho otsatirawa, fayilo yowerengera yokhayo Extension ikhoza kuwoneka ndi chowonjezera chochokera ku dzina. Ngati wosuta atsitsa fayiloyo, Drive imapanga dzina lomaliza kuchokera pamutu (ndi kukulitsa kwake).
- Mawu ofotokozera (contentHints.indexableText): Sungani zolemba ndi mitundu wamba (ma PDF, zithunzi zothandizidwa ndi OCR, ndi zina) mwachisawawa. Ngati pulogalamu yanu imasunga mitundu ina (zojambula, makanema, njira zazifupi), mutha kupereka mawu osavuta kuti muwongolere kusaka. Mawuwa asinthidwa ngati HTML: ngati mutadutsa chingwe chokhala ndi ma tag, zolembazo ndizolondolera, osati mawonekedwe a tag. Pali malire a kukula kwa 128KB kwa contentHints.indexableText, ndipo tikulimbikitsidwa kuti muzisintha pa save iliyonse ndikusunga kuti ikhale yogwirizana ndi fayilo.
- Tizithunzi (contentHints.thumbnail): Drive imapanga tizithunzi tamitundu yambiri, koma pamapangidwe omwe samangopanga zokha, mutha kuyika zanu mukapanga kapena kusintha fayiloyo. Muyenera kuyika chithunzichi kukhala URL-safe base64 ndi mimeType yofananira. Malamulo ofunikira: Mawonekedwe othandizidwa ndi PNG, GIF, kapena JPG; m'lifupi mwake ndi 1600px (ochepera 220px), ndipo kukula kwake kwakukulu ndi 2MB. Zing'onozing'ono ndizosavomerezeka pamene zomwe zili mufayilo zikusintha; zosintha za metadata sizitero.
- Kufikira tizithunzi: Munda wa ThumbnailLink umabweretsanso ulalo waufupi, wopezeka pokhapokha ngati pulogalamuyo ili ndi chilolezo chowerenga fayilo (ngati siili pagulu, muyenera kuipempha ndi zidziwitso). Mutha kufunsa fayilo inayake kapena mndandanda wosefedwa ndi mtundu.
- Zolemba: Drive imakupatsani mwayi wogwirizanitsa zilembo ndi mafayilo. Kuti muwapeze, mutha kugwiritsa ntchito mafayilo.listLabels, ndipo kuti muwasinthe, muyenera kutchula dzina laId ndi fileId. Makinawa ndi othandiza pakugawa ndipo, ngati kuli kofunikira, "kuyeretsa" magulu osafunikira popanda kukhudza zomwe zili.
Chotsani metadata mu Google Drive: metadata "yobisika" pafayiloyo
Palibe batani lamatsenga kuti muchotse metadata mu Google Drive (monga EXIF pazithunzi kapena ma PDF ophatikizidwa). Drive imayang'anira metadata yakeyake, koma metadata mkati mwa fayiloyo imadalira chida chomwe chidachipanga.
Mchitidwe analimbikitsa ndi yeretsani fayilo musanayikweze ku Drive, Kugwiritsa ntchito zida zamakina kapena mapulogalamu apadera omwe amachotsa deta ya EXIF pazithunzi kapena zolemba. Mwanjira imeneyi, zomwe mumasunga mu Drive zimafika "zoyeretsedwa."
Ngati muli ndi mafayilo omwe adakwezedwa kale ndi metadata yophatikizidwa, m'malo mochotsa metadata mu Google Drive, ndikosavuta. tsitsani, yeretsani ndikuyikanso, kulowetsamo choyambirira ngati kuli kotheka. Ndi ma PDF kapena zithunzi, izi ndizofala mukafuna kuteteza olemba, malo, kapena mbiri yosintha.
Kwa gawo lina la Drive, yang'anani pakusintha dzina, ma label ndi contentHints (indexableText/thumbnail), amene ali pansi pa ulamuliro wanu. Ngati mumawongoleranso zilolezo zolowa, mumachepetsanso kuwonekera kwa metadata yowonekera (mwachitsanzo, maulalo azithunzi omwe ali ndi ufulu wowerenga).
Musaiwale kuti Kusintha metadata yokha ya Drive sikuchotsa EXIF kapena katundu wamkati. Chifukwa chake, njira yanu iyenera kuphatikizira kuyeretsa kale fayilo ndi kasamalidwe kabwino ka metadata komwe Drive imakulolani kuti mugwire.
Metadata yosokonezeka nthawi zambiri mu Google Cloud: VMs, gcloud, ndi malire
Ngati mutagwira ntchito ndi Google Cloud, mudzawona zambiri amawongolera za "metadata" yomwe imatanthawuza ku Compute Engine kapena Cloud Storage, osati Drive. Ngakhale zili choncho, mufuna kudziwa mfundo izi kuti musasokoneze pofufuza.
Kukonzekera koyambirira kwa gcloud CLI
Mukakhazikitsa Google Cloud CLI, yambitsani ndi:
gcloud init
Ndikofunika kuwonetsetsa kuti muli ndi mtundu waposachedwa kwambiri ndi:
gcloud components update
Ngati mugwiritsa ntchito zidziwitso zakunja, Lowani ndi chizindikiritso chanu musanagwire ntchito ndi gcloud, makamaka ngati mutsimikize kuyimba mafoni a REST kuchokera kudera lanu. Zitsanzo za REST API zitha kugwiritsa ntchito zidziwitso zomwe mudazikonza mu gcloud.
VM
Zilolezo ndi maudindo (Compute Engine): Kuti muwonjezere, kusintha, kapena kufufuta ma metadata anu pa ma VM, mufunika zilolezo zoyenera za IAM. Zitsanzo zodziwika bwino ndi izi:
- Ngati ma VM anu amagwiritsa ntchito maakaunti a ntchito: chilolezo
iam.serviceAccounts.actAsmu akaunti yautumiki kapena polojekiti. - Metadata ya polojekiti:
compute.projects.getycompute.projects.setCommonInstanceMetadata. - Zonal metadata:
compute.instanceSettings.getycompute.instanceSettings.updateza malo oyenera. - Chitsanzo cha metadata:
compute.instances.getycompute.instances.setMetadata.
Zofooka
Izi ndi zolepheretsa zazikulu zomwe tidakumana nazo poyesa kuchotsa metadata mu Google Drive:
- Kuchepetsa Kukula (Compute Engine): Zolemba zonse za metadata zophatikizidwa zili pa 512 KB. Kiyi iliyonse imakhala ndi ma 128 byte, ndipo mtengo uliwonse umangokhala 256 KB. Ngati, mwachitsanzo, mugwiritsa ntchito kiyi ya ssh-keys ndikudutsa malire a 256 KB, simungathe kuwonjezera makiyi ena mpaka mutatsuka.
- Zolemba zazikulu ndi zazing'ono: Makiyi amakhudzidwa ndi nkhani; ma values nawonso, kupatula Booleans. Mu zonal, simungathe kupanga makiyi awiri omwe amasiyana pokhapokha (zonal-metadata-key vs. ZONAL-METADATA-KEY).
- Zonal metadata: zimayikidwa kapena kuchotsedwa pogwiritsa ntchito gcloud kapena REST. Simungathe kutanthauzira zonal makiyi a SSH (makiyi a ssh). Mundondomeko yomveka bwino ya projekiti / chikwatu, ngati pali ma projekiti ndi ma zonal makiyi omwewo, mtengo wa zonal umakhala wotsogola m'malo ake.
- Makhalidwe a boolean othandizidwa: Kuphatikiza pa ZOONA/BODZA, mutha kugwiritsa ntchito Y/Inde/1 ndi N/No/0 (zosamva nkhani).
- Masinthidwe Scopes (Compute Engine):
- Ntchito: metadata yofanana ndi ma VM onse mu polojekitiyi.
- Zonal: zolemba zomwe zimakhudza ma VM onse m'dera linalake ndipo zimatha kupitilira mtengo wa polojekiti.
- Chitsanzo: metadata ya VM yeniyeni (yopangidwa kapena ilipo kale).

Tizithunzi, kulondolera, ndi kupeza metadata mu Drive (REST ndi machitidwe abwino)
Tiyeni tsopano tiwone ntchito ya tizithunzi tikamachotsa metadata mu Google Drive. Komanso njira yabwino kwambiri yothetsera vutoli:
- Kutsimikizira kwa REST pamalopo: Ngati mukuyesa zitsanzo za REST kuchokera pamakina anu, gwiritsani ntchito zizindikiro zokhazikitsidwa ndi gcloud. Mwanjira imeneyi, mafoni anu a Drive API adzalemekeza dzina lanu ndi zilolezo zomwe mwakhazikitsa kale.
- Kukwezera chithunzithunzi mwamakonda: set contentHints.thumbnail ndi magawo awiri: chithunzi cha URL-safe base64 ndi mimeType yolondola. Ngati Drive ingathe kupanga chithunzithunzi, idzagwiritsa ntchito yake ndikudumpha chanu. Apo ayi, idzagwiritsa ntchito yomwe mumapereka.
Malamulo ofunikira azithunzi mu Drive:
- Mawonekedwe: PNG, GIF kapena JPG.
- Kukula kovomerezeka: 1600 px (osachepera 220 px).
- Kukula kwakukulu: 2MB.
- Sinthani chithunzithunzi ndi chilichonse chosunga ngati chikadali chofunikira.
Zofunika za kusavomerezeka: Tizithunzi ndizosavomerezeka ngati zomwe zili mufayilo zasinthidwa; zosintha za metadata sizisintha. Mukangosintha ma tag kapena dzina, musayembekezere chithunzi chatsopano pokhapokha mutasintha fayilo.
Zolemba zolozera
Musayese "kupusitsa" kufufuza ndi buzzwords. Jambulani malingaliro ndi mawu omwe wogwiritsa ntchito angafufuze bwino fayiloyo, ndi onani malire a 128KB. Sinthani nthawi zonse zikasintha kwambiri.
Ikani mayina osagwirizana ndi zowonjezeraNgati n'kotheka, phatikizani zowonjezera mu dzina pamene mukukweza; ngati ikusowa, Drive idzayesa kutsimikizira ndi MIME. Kusunga mayina momveka bwino kumapewa kusamveka bwino ndikupangitsa kuti kusaka kosavuta kowonjezera.
Tags mu Drive
Kuti musinthe zilembo, zindikirani zozindikiritsa zofunika. Mufunika labelId ndi fileId file. Mutha kuzilemba kaye ndi mafayilo.listLabels ndiyeno gwiritsani ntchito zosintha zofananira pafayilo yomwe mukufuna.
// Al modificar etiquetas de un archivo en Drive:
// - labelId: identificador de la etiqueta a cambiar
// - fileId: identificador del archivo al que aplicas la etiqueta
// Usa files.listLabels para localizarlas antes de actualizar.
Kumbukirani kuti, Ngakhale Drive ndiye cholinga chake, zochitika zambiri zimaphatikiza Drive ndi Cloud Storage kapena ntchito zina, Chifukwa chake muwona zitsanzo za Kusungirako kuti muyang'ane mawonekedwe a chinthu.
// Ejemplo en Go para obtener atributos de un objeto en Cloud Storage (no Drive)
// e imprimir metadatos como ContentType, CacheControl, MD5, etc.
// Útil si tu flujo sube primero a Storage y luego a Drive.
import (
"context"
"fmt"
"io"
"time"
"cloud.google.com/go/storage"
)
func getMetadata(w io.Writer, bucket, object string) (*storage.ObjectAttrs, error) {
ctx := context.Background()
client, err := storage.NewClient(ctx)
if err != nil { return nil, fmt.Errorf("storage.NewClient: %w", err) }
defer client.Close()
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
o := client.Bucket(bucket).Object(object)
attrs, err := o.Attrs(ctx)
if err != nil { return nil, fmt.Errorf("Object(%q).Attrs: %w", object, err) }
fmt.Fprintf(w, "Bucket: %v\n", attrs.Bucket)
fmt.Fprintf(w, "CacheControl: %v\n", attrs.CacheControl)
fmt.Fprintf(w, "ContentDisposition: %v\n", attrs.ContentDisposition)
fmt.Fprintf(w, "ContentEncoding: %v\n", attrs.ContentEncoding)
fmt.Fprintf(w, "ContentLanguage: %v\n", attrs.ContentLanguage)
fmt.Fprintf(w, "ContentType: %v\n", attrs.ContentType)
fmt.Fprintf(w, "Crc32c: %v\n", attrs.CRC32C)
fmt.Fprintf(w, "Generation: %v\n", attrs.Generation)
fmt.Fprintf(w, "KmsKeyName: %v\n", attrs.KMSKeyName)
fmt.Fprintf(w, "Md5Hash: %v\n", attrs.MD5)
fmt.Fprintf(w, "MediaLink: %v\n", attrs.MediaLink)
fmt.Fprintf(w, "Metageneration: %v\n", attrs.Metageneration)
fmt.Fprintf(w, "Name: %v\n", attrs.Name)
fmt.Fprintf(w, "Size: %v\n", attrs.Size)
fmt.Fprintf(w, "StorageClass: %v\n", attrs.StorageClass)
fmt.Fprintf(w, "TimeCreated: %v\n", attrs.Created)
fmt.Fprintf(w, "Updated: %v\n", attrs.Updated)
fmt.Fprintf(w, "Event-based hold enabled? %t\n", attrs.EventBasedHold)
fmt.Fprintf(w, "Temporary hold enabled? %t\n", attrs.TemporaryHold)
fmt.Fprintf(w, "Retention expiration time %v\n", attrs.RetentionExpirationTime)
fmt.Fprintf(w, "Custom time %v\n", attrs.CustomTime)
fmt.Fprintf(w, "Retention: %+v\n", attrs.Retention)
fmt.Fprintf(w, "\n\nMetadata\n")
for key, value := range attrs.Metadata {
fmt.Fprintf(w, "\t%v = %v\n", key, value)
}
return attrs, nil
}
Kuchotsa mafayilo motsutsana ndi kufufuta metadata mu Google Drive
Ngati zomwe mukufuna Chotsani fayilo kuchokera ku DriveMonga eni ake, mutha kuyisuntha kupita ku zinyalala kuchokera pa intaneti podina kumanja ndikusankha Pitani ku Zinyalala. Ngati mwiniwakeyo ndi munthu wina, mutha "Chotsani" fayilo kuchokera pamawonedwe anu; ena adzachiwonabe.
Para Kuti muchotse fayiloyo, muyenera kutaya zinyalala kapena kugwiritsa ntchito njira yochotseratu, Pankhaniyi, simudzatha kuchibwezeretsa. Izi zokha, "sizimachotsa metadata" pamafayilo ena - zimangokhudza chinthucho.
Simungathe kufufuta metadata mu Google Drive kuchokera pamafayilo omwe mulibe, chifukwa ulamuliro wawo ndi wa munthu amene adawalenga kapena wina yemwe ali ndi zilolezo zapamwamba mkati mwa bungwe. Muzochitika izi, mumangochotsa mwayi wanu kapena mawonekedwe.
Zogwirizana ndi metadata: Kuchotsa fayilo kumachotsa metadata yake mu Drive pamodzi nayo, koma sizikhudza metadata m'makope ena kapena metadata yophatikizidwa muzolemba zina zomwe zimakhalabe mudongosolo.
Ndi zonse pamwambapa, tsopano mukhoza kusiyanitsa bwino Kodi metadata Drive imawongolera chiyani (dzina, ma tag, malingaliro osakira, ndi tizithunzi), momwe mungawafunse kudzera pa REST, ndi njira ziti zabwino zomwe mungatsatire poyeretsa deta yosungidwa musanayike, ndi malire ndi zilolezo zomwe zimabwera mukakumana ndi zolemba za Google Cloud zomwe zimakamba za "metadata" muzinthu zina.
Mkonzi wokhazikika pazaukadaulo komanso nkhani zapaintaneti yemwe ali ndi zaka zopitilira khumi pazama media osiyanasiyana. Ndagwira ntchito ngati mkonzi komanso wopanga zinthu pa e-commerce, kulumikizana, kutsatsa pa intaneti ndi makampani otsatsa. Ndalembanso pamawebusayiti azachuma, azachuma ndi magawo ena. Ntchito yanga ndi chidwi changanso. Tsopano, kudzera mu zolemba zanga mu Tecnobits, Ndimayesetsa kufufuza nkhani zonse ndi mwayi watsopano umene dziko laukadaulo limatipatsa tsiku lililonse kuti tisinthe miyoyo yathu.