Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Le service de transfert de stockage peut copier des fichiers à partir d'une liste d'URL publiques vers votre bucket Cloud Storage.
Lorsque vous créez un transfert, vous fournissez un lien vers un fichier TSV (valeurs séparées par des tabulations) contenant les URL et les informations des objets à transférer. Le fichier TSV peut être hébergé dans n'importe quel emplacement HTTP ou HTTPS accessible au public, ou stocké dans un bucket Cloud Storage.
Cette page explique comment créer une liste d'URL et la transmettre à la commande de création de tâche.
Exigences concernant les fichiers sources
Les URL doivent être accessibles au public et utiliser les protocoles HTTP ou HTTPS.
Le serveur hébergeant chaque objet :
Ne doit pas refuser l'accès à l'objet avec un robots.txt.
Est compatible avec les requêtes Range
Renvoie un en-tête Content-Length dans chaque réponse.
Format de liste d'URL
Une liste d'URL doit respecter les exigences suivantes:
Le fichier doit être au format valeurs séparées par des tabulations.
Les URL doivent être triées dans l'ordre lexicographique UTF-8.
La première ligne doit spécifier TsvHttpData-1.0.
Après la première ligne, spécifiez un objet par ligne.
Chaque ligne doit contenir l'URL, et peut également contenir la taille du fichier et la somme de contrôle MD5 encodée en base64 de l'objet.
Voici un exemple de fichier TSV spécifiant deux objets à transférer. Notez que sur cette page, les tabulations sont affichées sous forme d'espaces. Pour votre propre fichier, veillez à utiliser des tabulations entre les champs.
Assurez-vous que la taille spécifiée correspond à la taille réelle de l'objet lors de son extraction. Si la taille de l'objet reçu par Cloud Storage ne correspond pas à la taille spécifiée, le transfert de l'objet échouera.
(Facultatif) Somme de contrôle MD5 encodée en base64 de l'objet.
Assurez-vous que la somme de contrôle MD5 spécifiée correspond à celle calculée à partir des octets transférés. Si la somme de contrôle MD5 de l'objet reçu par Cloud Storage ne correspond pas à celle spécifiée, le transfert de l'objet échouera.
Bien que la taille de l'objet et les valeurs de somme de contrôle MD5 soient facultatives, nous vous recommandons vivement de les inclure pour garantir l'intégrité des données.
Héberger la liste d'URL
La liste d'URL peut être hébergée dans l'un des deux emplacements suivants:
URL accessible publiquement.
Un bucket Cloud Storage auquel l'agent de service du service de transfert de stockage a été autorisé à accéder.
URL accessibles au public
Lorsque vous stockez la liste d'URL sur une URL accessible au public, les exigences suivantes s'appliquent:
L'URL doit commencer par http:// ou https://.
Le serveur doit définir un en-tête Etag fort dans la réponse HTTP lorsqu'il renvoie la liste d'URL.
Par exemple, vous pouvez stocker la liste dans un bucket Cloud Storage et partager l'objet publiquement pour obtenir un lien vers celui-ci.
Buckets Cloud Storage
Pour éviter de stocker votre liste dans un emplacement public, vous pouvez la stocker dans un bucket Cloud Storage et accorder l'accès à l'agent de service pour le service de transfert de stockage.
L'agent de service doit disposer des autorisations suivantes:
Autorisation storage.object.get sur l'objet. Pour ce faire, attribuez le rôle roles/storage.legacyObjectReader au bucket ou utilisez un rôle personnalisé.
Autorisation storage.buckets.get sur le bucket. Cette autorisation peut être accordée en attribuant le rôle roles/storage.legacyBucketReader ou un rôle personnalisé.
Pour accorder des autorisations à l'agent de service:
Un panneau interactif s'affiche, intitulé Essayer cette méthode.
Dans le panneau, sous Paramètres de requête, saisissez l'ID de votre projet. Le projet que vous spécifiez ici doit être le projet que vous utilisez pour gérer le service de transfert de stockage, qui peut être différent du projet du bucket de liste d'URL.
Cliquez sur Exécuter.
L'adresse e-mail de votre agent de service est renvoyée en tant que valeur de accountEmail et utilise le format project-PROJECT_NUMBER@storage-transfer-service.iam.gserviceaccount.com.
Copiez cette valeur.
Attribuer les rôles requis
Pour attribuer le rôle roles/storage.objectViewer et le rôle roles/storage.bucketViewer à l'agent de service sur le bucket contenant la liste d'URL, suivez les instructions de la section Définir et gérer des stratégies IAM sur des buckets.
Le compte principal que vous ajoutez est l'adresse e-mail de l'agent de service. Si nécessaire, l'identifiant principal est serviceAccount. Exemple : serviceAccount:project-PROJECT_NUMBER@storage-transfer-service.iam.gserviceaccount.com.
Créer une tâche de transfert de liste d'URL
Pour spécifier une liste d'URL lorsque vous créez une tâche de transfert, procédez comme suit:
Sous Type de source, sélectionnez Liste d'URL, puis cliquez sur Étape suivante.
Sous URL du fichier TSV, spécifiez l'URL de votre fichier de valeurs séparées par des tabulations (TSV). L'URL est une adresse HTTP/HTTPS (par exemple, https://example.com/urllist.tsv) ou un chemin d'accès Cloud Storage (par exemple, gs://my-bucket/urllist.tsv).
CLI gcloud
Pour créer une tâche de transfert, utilisez la commande gcloud transfer jobs create.
gcloudtransferjobscreate\SOURCEDESTINATION
Pour les transferts de liste d'URL, la valeur de SOURCE correspond à l'URL du fichier TSV. L'URL est une adresse HTTP/HTTPS (par exemple, https://example.com/urllist.tsv) ou un chemin d'accès Cloud Storage (par exemple, gs://my-bucket/urllist.tsv).
Pour en savoir plus sur la création de transferts à l'aide de gcloud CLI, consultez la section Créer des tâches de transfert.
REST
Pour créer une tâche de transfert de liste d'URL à l'aide de l'API REST, spécifiez l'URL du fichier TSV dans le champ listUrl:
La valeur de URL est une adresse HTTP/HTTPS (par exemple, https://example.com/urllist.tsv) ou un chemin d'accès Cloud Storage (par exemple, gs://my-bucket/urllist.tsv).
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/03 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/03 (UTC)."],[],[],null,["# Transfer from public URLs to Cloud Storage\n\nStorage Transfer Service can copy files from a list of public URLs to your\nCloud Storage bucket.\n\nWhen creating a transfer, you provide a link to a tab-separated values (TSV)\nfile containing the URLs and details of the objects to transfer. The TSV file\ncan be hosted in any publicly-accessible HTTP or HTTPS location; or can be\nstored in a Cloud Storage bucket.\n\nThis page explains how to create a URL list and pass it to the job creation\ncommand.\n\nSource file requirements\n------------------------\n\n- URLs must be publicly-accessible and use HTTP or HTTPS protocols.\n- The server hosting each object:\n - Must not deny access to the object with a `robots.txt`.\n - Supports `Range` requests.\n - Returns a `Content-Length` header in each response.\n\nURL list format\n---------------\n\nA URL list must adhere to the following requirements:\n\n- The file must be formatted as tab-separated values.\n- URLs must be in UTF-8 lexicographical order.\n- The first line must specify `TsvHttpData-1.0`.\n- After the first line, specify one object per row.\n- Each row must contain the URL, and may also contain the file size and the base64-encoded MD5 checksum of the object.\n\nThe following is a sample TSV file that specifies two objects to transfer. Note\nthat on this page the tabs are rendered as spaces; for your own file, make sure\nto use tabs between fields. \n\n TsvHttpData-1.0\n https://example.com/myfile.pdf 1357 wHENa08V36iPYAsOa2JAdw==\n https://example2.com/images/dataset1/flower.png 2468 R9acAaveoPd2y8nniLUYbw==\n\nEach line contains:\n\n- The HTTP or HTTPS URL of a source object.\n- (Optional) The size of the object in bytes.\n\n Ensure that the specified size matches the actual size of the object\n when it is fetched. If the size of the object received by\n Cloud Storage does not match the size specified, the object\n transfer will fail.\n- (Optional) The base64-encoded MD5 checksum of the object.\n\n Ensure that the specified MD5 checksum matches the MD5 checksum computed\n from the transferred bytes. If the MD5 checksum of the object received\n by Cloud Storage does not match the MD5 checksum specified, the\n object transfer will fail.\n | **Note:** Many checksumming tools output an object's MD5 checksum in base16-encoded format. Ensure the values provided are in base64-encoded format.\n\nWhile the object size and MD5 checksum values are optional, we strongly\nrecommend including them to help ensure data integrity.\n\nHosting the URL list\n--------------------\n\nThe URL list can be hosted in one of two locations:\n\n- A publicly-accessible URL.\n- A Cloud Storage bucket, to which the service agent for Storage Transfer Service\n has been granted access.\n\n### Publicly-accessible URLs\n\nWhen storing the URL list at a publicly-accessible URL, the following\nrequirements apply:\n\n- The URL must begin with `http://` or `https://`.\n- The server must set a strong `Etag` header in the HTTP response when it returns the URL list.\n\nFor example, you can store the list in a Cloud Storage bucket and\n[share the object publicly](/storage/docs/cloud-console#_sharingdata) to\nget a link to it.\n\n### Cloud Storage buckets\n\nTo avoid storing your list in a public location, you can store it in a\nCloud Storage bucket, and grant access to the service agent\nfor Storage Transfer Service.\n\nThe service agent must be granted the following permissions:\n\n- The `storage.object.get` permission on the object. This can be granted by granting the `roles/storage.legacyObjectReader` role on the bucket, or with a custom role.\n- The `storage.buckets.get` permission on the bucket. This can be granted by granting the `roles/storage.legacyBucketReader` role, or with a custom role.\n\nTo grant permissions to the service agent:\n\n#### Find the service agent's email\n\n1. Go to the\n [`googleServiceAccounts.get` reference\n page](/storage-transfer/docs/reference/rest/v1/googleServiceAccounts/get).\n\n An interactive panel opens, titled **Try this method**.\n2. In the panel, under **Request parameters**, enter your\n project ID. The project you specify here must be the project you're\n using to manage Storage Transfer Service, which might be different from the URL\n list bucket's project.\n\n3. Click **Execute**.\n\nYour service agent's email is returned as the value of `accountEmail` and\nuses the format\n`project-`\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e`@storage-transfer-service.iam.gserviceaccount.com`.\n\nCopy this value.\n\n#### Grant the required roles\n\nTo grant the `roles/storage.objectViewer` role and the\n`roles/storage.bucketViewer` role to the service agent on the bucket containing\nthe URL list, follow the instructions in\n[Set and manage IAM policies on buckets](/storage/docs/access-control/using-iam-permissions).\n\nThe principal you are adding is the service agent's email address. If required,\nthe principal identifier is `serviceAccount`. For example,\n`serviceAccount:project-`\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e`@storage-transfer-service.iam.gserviceaccount.com`.\n\nCreate a URL list transfer job\n------------------------------\n\nTo specify a URL list when creating a transfer job, follow these instructions: \n\n### Google Cloud console\n\nFollow the instructions in\n[Create a transfer job](/storage-transfer/docs/create-transfers#google-cloud-console).\n\nWhen choosing a source:\n\n1. Under **Source type** , select **URL list** and click **Next step**.\n\n2. Under **URL of TSV file** , provide the URL to your tab-separated values\n (TSV) file. The URL is either an HTTP/HTTPS address (e.g.\n `https://example.com/urllist.tsv`) or a Cloud Storage path\n (e.g. `gs://my-bucket/urllist.tsv`).\n\n### gcloud CLI\n\nTo create a new transfer job, use the `gcloud transfer jobs create`\ncommand. \n\n gcloud transfer jobs create \\\n \u003cvar translate=\"no\"\u003eSOURCE\u003c/var\u003e \u003cvar translate=\"no\"\u003eDESTINATION\u003c/var\u003e\n\nFor URL list transfers, the value of \u003cvar translate=\"no\"\u003eSOURCE\u003c/var\u003e is the URL of the\nTSV file. The URL is either an HTTP/HTTPS address (e.g.\n`https://example.com/urllist.tsv`) or a Cloud Storage path\n(e.g. `gs://my-bucket/urllist.tsv`).\n\nFor more information on creating transfers using gcloud CLI, see\n[Create transfer jobs](/storage-transfer/docs/create-transfers#gcloud-cli).\n\n### REST\n\nTo create a URL list transfer job using the REST API, specify the URL of the\nTSV file in the `listUrl` field: \n\n {\n \"projectId\": \"\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\",\n \"transferSpec\": {\n \"httpDataSource\": {\n \"listUrl\": \"\u003cvar translate=\"no\"\u003eURL\u003c/var\u003e\"\n },\n \"gcsDataSink\": {\n \"bucketName\": \"DESTINATION_BUCKET\"\n }\n },\n \"status\": \"ENABLED\"\n }\n\nThe value of \u003cvar translate=\"no\"\u003eURL\u003c/var\u003e is either an HTTP/HTTPS address (e.g.\n`https://example.com/urllist.tsv`) or a Cloud Storage path\n(e.g. `gs://my-bucket/urllist.tsv`).\n\nFor more details on creating transfers using the REST API, see the\n[REST API reference](/storage-transfer/docs/reference/rest/v1/transferJobs/create)."]]