Flutter에서 Cloud Storage 오류 처리
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
앱을 만들다 보면 예기치 않은 상황으로 인해 오류가 발생하기도 합니다.
의심스러운 경우 함수에서 발생한 예외를 포착하고 오류 메시지 내용을 확인합니다.
final storageRef = FirebaseStorage.instance.ref().child("files/uid");
try {
final listResult = await storageRef.listAll();
} on FirebaseException catch (e) {
// Caught an exception from Firebase.
print("Failed with error '${e.code}': ${e.message}");
}
오류 메시지 처리
오류가 발생하는 이유는 파일이 없는 경우, 사용자에게 파일 액세스 권한이 없는 경우, 사용자가 파일 업로드를 취소한 경우 등
다양합니다.
문제를 정확히 진단하고 오류를 해결하는 데 도움이 되도록 클라이언트에서 발생하는 모든 오류와 발생 원인이 아래에 나와 있습니다.
코드 |
설명 |
storage/unknown |
알 수 없는 오류가 발생했습니다. |
storage/object-not-found |
해당 참조에 객체가 없습니다. |
storage/bucket-not-found |
Cloud Storage에 구성된 버킷이 없습니다. |
storage/project-not-found |
Cloud Storage에 구성된 프로젝트가 없습니다. |
storage/quota-exceeded |
Cloud Storage 버킷의 할당량이 초과되었습니다. Spark 요금제를 사용하고 있으면 사용한 만큼만 지불하는 Blaze 요금제로 업그레이드하는 것이 좋습니다. 이미 Blaze 요금제를 사용하고 있으면 Firebase 지원팀에 문의하세요.
중요: 2025년 10월 1일부터 기본 버킷을 포함하여 Cloud Storage를 사용하려면 Blaze 요금제를 사용해야 합니다. |
storage/unauthenticated |
사용자가 인증되지 않았습니다. 인증한 후 다시 시도해 보세요. |
storage/unauthorized |
사용자에게 해당 작업을 수행할 수 있는 권한이 없습니다. 보안 규칙이 올바른지 확인해 보세요. |
storage/retry-limit-exceeded |
작업(업로드, 다운로드, 삭제 등)의 최대 제한 시간이 초과되었습니다. 다시 업로드해 보세요. |
storage/invalid-checksum |
클라이언트의 파일과 서버에서 수신한 파일의 체크섬이 일치하지 않습니다. 다시 업로드해 보세요. |
storage/canceled |
사용자가 작업을 취소했습니다. |
storage/invalid-event-name |
이벤트 이름이 잘못되었습니다. [running , progress , pause ] 중 하나여야 합니다. |
storage/invalid-url |
refFromURL() 에 제공된 URL이 잘못되었습니다. gs://bucket/object 또는 https://firebasestorage.googleapis.com/v0/b/bucket/o/object?token=<TOKEN> 형식이어야 합니다. |
storage/invalid-argument |
put() 에 전달되는 인수는 File , Blob 또는 UInt8 배열이어야 합니다. putString() 에 전달되는 인수는 원시, Base64 또는 Base64URL 문자열이어야 합니다. |
storage/no-default-bucket |
구성의 storageBucket 속성에 설정된 버킷이 없습니다. |
storage/cannot-slice-blob |
로컬 파일이 변경(삭제, 재저장 등)되었을 때 흔히 발생합니다. 파일이 변경되지 않았는지 확인한 후 다시 업로드해 보세요. |
storage/server-file-wrong-size |
클라이언트의 파일과 서버에서 수신한 파일의 크기가 일치하지 않습니다. 다시 업로드해 보세요. |
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-14(UTC)
[null,null,["최종 업데이트: 2025-08-14(UTC)"],[],[],null,["\u003cbr /\u003e\n\nSometimes when you're building an app, things don't go as planned and an\nerror occurs!\n\nWhen in doubt, catch the exception thrown by the function\nand see what the error message has to say. \n\n final storageRef = FirebaseStorage.instance.ref().child(\"files/uid\");\n try {\n final listResult = await storageRef.listAll();\n } on FirebaseException catch (e) {\n // Caught an exception from Firebase.\n print(\"Failed with error '${e.code}': ${e.message}\");\n }\n\n| **Note:** By default, a Cloud Storage for Firebase bucket requires Firebase Authentication to perform any action on the bucket's data or files. You can change your Firebase Security Rules for Cloud Storage to [allow unauthenticated access for specific situations](/docs/storage/security/rules-conditions#public). However, for most situations, we strongly recommend [restricting access and setting up robust security rules](/docs/storage/security/get-started) (especially for production apps). Note that if you use Google App Engine and have a default Cloud Storage bucket with a name format of `*.appspot.com`, you may need to consider [how your security rules impact access to App Engine files](/docs/storage/gcp-integration#security-rules-and-app-engine-files).\n\nHandle Error Messages\n\nThere are a number of reasons why errors may occur, including the file\nnot existing, the user not having permission to access the desired file, or the\nuser cancelling the file upload.\n\nTo properly diagnose the issue and handle the error, here is a full list of\nall the errors our client will raise, and how they occurred.\n\n| Code | Description |\n|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `storage/unknown` | An unknown error occurred. |\n| `storage/object-not-found` | No object exists at the desired reference. |\n| `storage/bucket-not-found` | No bucket is configured for Cloud Storage |\n| `storage/project-not-found` | No project is configured for Cloud Storage |\n| `storage/quota-exceeded` | Quota on your Cloud Storage bucket has been exceeded. If you're on the Spark pricing plan, consider upgrading to the [pay-as-you-go Blaze pricing plan](/pricing). If you're already on the Blaze pricing plan, reach out to Firebase Support. **Important** : Starting October 1, 2025, the [Blaze pricing plan will be *required* to use Cloud Storage](/docs/storage/faqs-storage-changes-announced-sept-2024), even default buckets. |\n| `storage/unauthenticated` | User is unauthenticated, please authenticate and try again. |\n| `storage/unauthorized` | User is not authorized to perform the desired action, check your security rules to ensure they are correct. |\n| `storage/retry-limit-exceeded` | The maximum time limit on an operation (upload, download, delete, etc.) has been excceded. Try uploading again. |\n| `storage/invalid-checksum` | File on the client does not match the checksum of the file received by the server. Try uploading again. |\n| `storage/canceled` | User canceled the operation. |\n| `storage/invalid-event-name` | Invalid event name provided. Must be one of \\[`running`, `progress`, `pause`\\] |\n| `storage/invalid-url` | Invalid URL provided to `refFromURL()`. Must be of the form: `gs://bucket/object` or `https://firebasestorage.googleapis.com/v0/b/bucket/o/object?token=\u003cTOKEN\u003e` |\n| `storage/invalid-argument` | The argument passed to `put()` must be `File`, `Blob`, or `UInt8` Array. The argument passed to `putString()` must be a raw, `Base64`, or `Base64URL` string. |\n| `storage/no-default-bucket` | No bucket has been set in your config's `storageBucket` property. |\n| `storage/cannot-slice-blob` | Commonly occurs when the local file has changed (deleted, saved again, etc.). Try uploading again after verifying that the file hasn't changed. |\n| `storage/server-file-wrong-size` | File on the client does not match the size of the file received by the server. Try uploading again. |"]]