Ruby 앱에서 런타임 중에 파일을 읽고 써야 하는 경우 또는 동영상, 이미지, 기타 정적 콘텐츠와 같은 파일을 제공해야 하는 경우 Cloud Storage 버킷을 사용하는 것이 좋습니다.
앱을 만들면 App Engine이 기본 버킷을 만듭니다. 이 버킷은 처음 5GB의 스토리지를 무료로 제공하며 Cloud Storage I/O 작업의 무료 할당량을 포함합니다. 다른 Cloud Storage 버킷을 만들 수 있지만 기본 버킷에만 처음 5GB의 무료 스토리지가 포함되어 있습니다.
App Engine에 Cloud Storage 사용
App Engine 앱에서 Cloud Storage 버킷을 사용하려면 다음 안내를 따르세요.
App Engine 프로젝트에서 기존 버킷의 이름을 확인합니다. Cloud Storage에서 데이터를 업로드하거나 다운로드할 때 이 이름을 지정합니다.
Cloud Storage 버킷의 이름을 앱에 하드 코딩하지 않고 앱의 환경 변수에 저장하는 것이 좋습니다.
앱에서 다음을 수행하여 Cloud Storage를 종속 항목으로 선언합니다.
Go
go get cloud.google.com/go/storage 명령어 사용 또는 앱의 go.mod 파일에서 종속 항목을 선언할 수 있습니다. 종속 항목 지정에 대해 자세히 알아보세요.
버킷에서 데이터를 업로드 또는 다운로드하려면 Google Cloud 클라이언트 라이브러리를 사용합니다.
앱을 만들 때 App Engine이 처음 5GB의 무료 스토리지를 제공하는 기본 버킷을 만듭니다. 기본 버킷에는 Cloud Storage I/O 작업을 위한 무료 할당량도 포함되어 있습니다. 자세한 내용은 가격 책정, 할당량, 한도를 참조하세요. 5GB 제한을 초과하는 스토리지를 사용하면 요금이 청구됩니다.
기본 버킷 이름의 형식은 다음과 같습니다.
project-id.appspot.com
App Engine은 앱의 새 버전을 배포할 때 임시 스토리지에 사용할 버킷도 만듭니다. 이름이 staging.project-id.appspot.com인 이 버킷은 App Engine에서만 사용됩니다. 앱은 이 버킷과 상호작용할 수 없습니다.
버킷 권한 설정
앱과 연결된 서비스 계정에는 프로젝트에서 버킷을 읽고 쓸 수 있는 권한이 필요합니다. 필요한 권한을 알아보려면 Cloud Storage의 IAM 역할을 참조하세요.
자동 역할 부여를 중지한 경우 기본 서비스 계정에 부여할 역할을 결정한 후 직접 이러한 역할을 부여해야 합니다.
기본 서비스 계정에 이미 편집자 역할이 있으면 편집자 역할을 권한이 더 낮은 역할로 바꾸는 것이 좋습니다.서비스 계정 역할을 안전하게 수정하려면 정책 시뮬레이터를 사용하여 변경사항의 영향을 확인한 후 적절한 역할을 부여하고 취소합니다.
다른 사용자, 앱 또는 프로젝트에서 버킷과 해당 콘텐츠에 액세스하도록 허용하는 방법은 버킷 권한 설정을 참조하세요.
로컬 개발 서버에서 Cloud Storage 사용
App Engine 로컬 개발 서버는 Cloud Storage를 에뮬레이션하지 않으므로 모든 Cloud Storage 요청은 인터넷을 통해 실제 Cloud Storage 버킷에 전송해야 합니다.
가격 책정, 할당량, 한도
Cloud Storage 클라이언트 라이브러리에서 Cloud Storage를 호출할 때 부과되는 대역폭 요금이 없습니다. 하지만 작업 비용은 청구됩니다.
또한 라이브러리가 Cloud Storage와 상호작용하는 데 URL Fetch 서비스를 사용하므로 호출 수가 URL Fetch 할당량에 반영됩니다.
Cloud Storage는 유료 서비스이며 Cloud Storage 가격표에 따라 비용이 청구됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eCloud Storage is recommended for apps needing to read/write files or serve static content, with App Engine creating a default bucket providing 5GB of free storage.\u003c/p\u003e\n"],["\u003cp\u003eTo use Cloud Storage, you need to list the names of your project's existing buckets and consider storing them as environment variables in your app.\u003c/p\u003e\n"],["\u003cp\u003eVarious programming languages like Go, Java, Node.js, PHP, Python, and Ruby can utilize the Google Cloud Client Library to upload or download data from Cloud Storage buckets.\u003c/p\u003e\n"],["\u003cp\u003eThe service account associated with your app needs proper IAM permissions to read/write to buckets, and disabling automatic role grants is recommended, with safe role modification using Policy Simulator.\u003c/p\u003e\n"],["\u003cp\u003eThe App Engine local development server doesn't emulate Cloud Storage, and while there are no bandwidth charges for client library calls, operation charges and URL fetch quota usage apply.\u003c/p\u003e\n"]]],[],null,["# Use Cloud Storage\n\nGo Java Node.js PHP Python Ruby\n\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nIf your app needs to read and write files during runtime,\nor serve files such as movies, images or other static content, we recommend you\nuse a [Cloud Storage](/storage/docs) bucket.\n\nApp Engine creates a [default bucket](#default_bucket) when you create\nan app. This bucket provides the first 5GB of storage for free and includes a\nfree quota for Cloud Storage I/O operations. You can\n[create other Cloud Storage buckets](/storage/docs/creating-buckets),\nbut only the default bucket includes the first 5GB of storage for free.\n\nUsing Cloud Storage with App Engine\n-----------------------------------\n\nTo use a Cloud Storage bucket from an App Engine app:\n\n1. [View the names of the existing buckets](/storage/docs/listing-buckets)\n in your App Engine project. You'll specify these names when you\n upload or download data from Cloud Storage.\n\n We recommend that you store the names of your Cloud Storage buckets\n in your app's [environment variables](/appengine/docs/standard/reference/app-yaml#environment_variables)\n instead of hard coding them into your app.\n2. In your app, declare Cloud Storage as a dependency by doing the following:\n\n ### Go\n\n Using the `go get cloud.google.com/go/storage` command. Alternatively, you can declare\n dependencies in your app's `go.mod` file. Learn more\n [about specifying dependencies](/appengine/docs/standard/go/specifying-dependencies).\n\n Use the Google Cloud Client Library to\n [upload](/storage/docs/uploading-objects)\n or [download](/storage/docs/downloading-objects)\n data from your buckets.\n\n For information about serving static content, see [Storing and Serving\n Static Files](/appengine/docs/standard/serving-static-files).\n\n ### Java\n\n [Add the library to your app's dependencies file](/storage/docs/reference/libraries#client-libraries-install-java).\n\n Use the Google Cloud Client Library to\n [upload](/storage/docs/uploading-objects)\n or [download](/storage/docs/downloading-objects)\n data from your buckets.\n\n For information about serving static content, see [Storing and Serving\n Static Files](/appengine/docs/standard/serving-static-files).\n\n ### Node.js\n\n In `app.yaml`, add your project ID to the `GOOGLE_CLOUD_PROJECT` environment\n value. Then set the `GCLOUD_STORAGE_BUCKET` environment value to the name of\n the Cloud Storage bucket you created previously.\n\n Add `@google-cloud/storage` to your app's `package.json` file. Learn more\n [about specifying dependencies](/appengine/docs/standard/nodejs/specifying-dependencies).\n\n Use the Google Cloud Client Library to\n [upload](/storage/docs/uploading-objects)\n or [download](/storage/docs/downloading-objects)\n data from your buckets.\n\n For information about serving static content, see [Storing and Serving\n Static Files](/appengine/docs/standard/serving-static-files).\n\n See the [`README.md` file](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/storage/standard/README.md)\n for instructions on running and testing locally.\n\n ### PHP\n\n Add `google/cloud-storage` to your app's `composer.json` file and running\n `composer install` from your app's directory. Learn more\n [about specifying dependencies](/appengine/docs/standard/php-gen2/specifying-dependencies).\n\n [Register `Google\\Cloud\\Storage\\StorageClient` as the\n stream wrapper](https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/v0.122.0/storage/storageclient?method=registerStreamWrapper) for your app.\n Then use the `gs` protocol to read and write files.\n\n See an [example of registering and using the stream\n wrapper](https://github.com/googleapis/google-cloud-php/tree/master/Storage#stream-wrapper).\n\n As an alternative, you can [use the Google Cloud client library directly](/storage/docs/reference/libraries).\n\n ### Python\n\n Add `google-cloud-storage` to your app's `requirements.txt` file. Learn more\n [about specifying dependencies](/appengine/docs/standard/python3/specifying-dependencies).\n\n Use the Google Cloud Client Library to\n [upload](/storage/docs/uploading-objects)\n or [download](/storage/docs/downloading-objects)\n data from your buckets.\n\n For information about serving static content, see [Storing and Serving\n Static Files](/appengine/docs/standard/serving-static-files).\n\n ### Ruby\n\n Add `google-cloud-storage` to your app's `Gemfile`. Learn more\n [about specifying dependencies](/appengine/docs/standard/ruby/specifying-dependencies).\n\n Use the Google Cloud Client Library to\n [upload](/storage/docs/uploading-objects)\n or [download](/storage/docs/downloading-objects)\n data from your buckets.\n\n For information about serving static content, see [Storing and Serving\n Static Files](/appengine/docs/standard/serving-static-files).\n\n### Using the default bucket\n\nWhen you create an app, App Engine creates a default bucket that\nprovides the first 5GB of storage for free. The default bucket also includes\na free quota for Cloud Storage I/O operations. See\n[Pricing, quotas, and limits](#pricing_quotas_and_limits) for details. You will\nbe charged for storage over the 5GB limit.\n\nThe name of the default bucket is in the following format: \n\n```\nproject-id.appspot.com\n```\n\n\u003cbr /\u003e\n\nApp Engine also creates a bucket that it uses for temporary\nstorage when it deploys new versions of your app. This bucket, named\n`staging.`\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e`.appspot.com`, is for use by\nApp Engine only. Apps can't interact with this bucket.\n\n### Set bucket permissions\n\nThe service account that's associated with your app needs permissions to read\nand write to buckets in your project. To learn which permissions are required,\nsee [IAM roles for\nCloud Storage](/storage/docs/access-control/iam-roles).\n\nTypically, the\nservice account that's associated with your app is the [default\nApp Engine service\naccount](/appengine/docs/standard/configure-service-accounts).\n\n\nDepending on your organization policy configuration, the default service account might\nautomatically be granted the [Editor role](/iam/docs/roles-overview#basic) on your\nproject. We strongly recommend that you disable the automatic role grant by [enforcing the `iam.automaticIamGrantsForDefaultServiceAccounts` organization policy\nconstraint](/resource-manager/docs/organization-policy/restricting-service-accounts#disable_service_account_default_grants). If you created your organization after May 3, 2024, this\nconstraint is enforced by default.\n\n\nIf you disable the automatic role grant, you must decide which roles to grant to the default\nservice accounts, and then [grant these\nroles](/iam/docs/granting-changing-revoking-access) yourself.\n\n\nIf the default service account already has the Editor role, we recommend that you replace the\nEditor role with less permissive roles.To safely modify the service account's roles, use [Policy Simulator](/policy-intelligence/docs/simulate-iam-policies) to see the impact of\nthe change, and then [grant and revoke the\nappropriate roles](/iam/docs/granting-changing-revoking-access).\n\n\u003cbr /\u003e\n\nFor information about allowing other users, apps, or projects to access a bucket\nand its contents, see\n[Setting bucket permissions](/storage/docs/access-control/using-iam-permissions).\n\nUsing Cloud Storage with the local development server\n-----------------------------------------------------\n\nThe App Engine local development server doesn't emulate Cloud Storage,\nso all Cloud Storage requests must be sent over the Internet to an\nactual Cloud Storage bucket.\n\nPricing, quotas, and limits\n---------------------------\n\nThere are no bandwidth charges associated with Cloud Storage client library\ncalls to Cloud Storage. However, there are\n[operations charges](/storage/pricing#operations-pricing).\nIn addition, the calls count against your\n[URL fetch quota](/appengine/docs/quotas#UrlFetch)\nas the library uses the URL Fetch service to interact with Cloud Storage.\n\nNotice that Cloud Storage is a pay-to-use service;\nyou will be charged according to the Cloud Storage\n[price sheet](/storage/pricing)."]]