Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
A API do App Engine para Ferramentas do Cloud Storage fornece métodos convenientes para a exibição de arquivos de imagem:
CloudStorageTools.getImageServingUrl()
CloudStorageTools.deleteImageServingUrl()
Uma vantagem de usar esse método para exibir imagens em vez de simplesmente tornar os arquivos públicos é a capacidade de redimensioná-las e cortá-las dinamicamente sem precisar armazená-las em tamanhos diferentes.
CloudStorageTools::getImageServingUrl retorna um URL de disponibilização para uma imagem. Se a imagem for exibida em uma
página HTTPS, defina secure_url como True para evitar avisos de conteúdo misto.
Esse URL é publicamente legível por todos, mas não pode ser adivinhado.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-19 UTC."],[[["\u003cp\u003eThe App Engine API offers \u003ccode\u003eCloudStorageTools.getImageServingUrl()\u003c/code\u003e to generate URLs for serving images stored in Cloud Storage, and \u003ccode\u003eCloudStorageTools.deleteImageServingUrl()\u003c/code\u003e to stop serving them.\u003c/p\u003e\n"],["\u003cp\u003eUsing \u003ccode\u003egetImageServingUrl\u003c/code\u003e allows for dynamic resizing and cropping of images without needing to store multiple image sizes, offering a significant advantage over directly making files public.\u003c/p\u003e\n"],["\u003cp\u003eOnly the first app that calls \u003ccode\u003egetImageServingUrl\u003c/code\u003e can serve a specific image; subsequent apps must copy the image first if they need to serve it.\u003c/p\u003e\n"],["\u003cp\u003eSetting \u003ccode\u003esecure_url\u003c/code\u003e to \u003ccode\u003eTrue\u003c/code\u003e when using \u003ccode\u003egetImageServingUrl\u003c/code\u003e ensures the image can be displayed on HTTPS pages without mixed-content warnings.\u003c/p\u003e\n"],["\u003cp\u003eTo remove the actual file you must use the PHP \u003ccode\u003eunlink()\u003c/code\u003e function and not the \u003ccode\u003edeleteImageServingUrl\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Serving Images\n\nThe App Engine API for Cloud Storage Tools provides convenience methods\nfor serving image files:\n\n- `CloudStorageTools.getImageServingUrl()`\n- `CloudStorageTools.deleteImageServingUrl()`\n\n| This page describes how to use the legacy bundled services and APIs. This API can only run in first-generation runtimes in the App Engine standard environment. If you are updating to the App Engine PHP 7/8 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/php-differences) to learn about your migration options for legacy bundled services.\n\n\u003cbr /\u003e\n\n| **Note:** When running your app locally on the [development server](/appengine/docs/legacy/standard/php/tools/using-local-server), you'll need to install [PIL](https://python-pillow.org/) if you wish to use the image sizing options described in this page.\n\nOne advantage of using this method to serve images over simply\n[making the files public](/appengine/docs/legacy/standard/php/googlestorage/public_access) is\nthe ability to resize and crop dynamically, without needing to store the\nimages in different sizes.\n\n[CloudStorageTools::getImageServingUrl](/appengine/docs/legacy/standard/php/refdocs/classes/google.appengine.api.cloud_storage.CloudStorageTools#method_getImageServingUrl)\nreturns a serving URL for an image. If the image will be displayed within an\nHTTPS page, set `secure_url` to `True` to avoid mixed-content warnings.\n\nNotice that this URL is publicly readable by everyone, but it is not \"guessable\".\n| **Important:** You cannot serve an image from two separate apps; only the first app that calls `getImageServingUrl` can get the URL to serve it because that app has obtained ownership of the image to serve it. Any other app that calls `getImageServingUrl` on the image will therefore be unsuccessful. If a second app needs to serve the image, the app needs to first copy the image and then invoke `getImageServingUrl` on the copy.\n\nTo stop serving the URL,\ncall [CloudStorageTools::deleteImageServingUrl](/appengine/docs/legacy/standard/php/refdocs/classes/google.appengine.api.cloud_storage.CloudStorageTools#method_deleteImageServingUrl).\n| **Note:** If you want to delete the file itself, use the PHP `unlink()` function.\n\nTo use this feature, import the `CloudStorageTools` class: \n\n use google\\appengine\\api\\cloud_storage\\CloudStorageTools;\n\nNow resize and crop the image `image.jpg`: \n\n $options = ['size' =\u003e 400, 'crop' =\u003e true];\n $image_file = \"gs://${my_bucket}/image.jpg\";\n $image_url = CloudStorageTools::getImageServingUrl($image_file, $options);"]]