사전 준비
에셋설치
유니티 코드
Firabase Storage API
175메가를 업로드 시켜보았다.
업로드 완료할 때까지 대략 10분 정도 걸린 것 같다.
또한, GC 로그가 지속적으로 찍혔다.
08-07 14:36:10.024: I/Unity(2967): Upload contents:175720000
08-07 14:36:10.024: I/Unity(2967):
08-07 14:36:10.024: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:36:10.104: I/Unity(2967): Progress: 0 of 175720000 bytes transferred.
08-07 14:36:10.104: I/Unity(2967):
08-07 14:36:10.104: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:36:10.104: I/Unity(2967): Progress: 0 of 175720000 bytes transferred.
08-07 14:36:10.104: I/Unity(2967):
08-07 14:36:10.104: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:36:10.294: D/dalvikvm(2967): GC_FOR_ALLOC freed 484K, 14% free 3423K/3968K, paused 2ms, total 2ms
08-07 14:36:10.874: D/dalvikvm(2967): GC_FOR_ALLOC freed 106K, 14% free 3418K/3968K, paused 2ms, total 2ms
08-07 14:36:10.874: I/dalvikvm-heap(2967): Grow heap (frag case) to 3.646MB for 262156-byte allocation
08-07 14:36:10.874: D/dalvikvm(2967): GC_FOR_ALLOC freed <1K, 14% free 3674K/4228K, paused 2ms, total 2ms
08-07 14:36:10.894: D/dalvikvm(2967): GC_FOR_ALLOC freed 17K, 13% free 3701K/4228K, paused 2ms, total 2ms
08-07 14:36:10.894: D/dalvikvm(2967): GC_FOR_ALLOC freed 19K, 13% free 3723K/4272K, paused 2ms, total 2ms
08-07 14:36:10.894: I/dalvikvm-heap(2967): Grow heap (frag case) to 3.779MB for 88548-byte allocation
08-07 14:36:10.894: D/dalvikvm(2967): GC_FOR_ALLOC freed 41K, 14% free 3768K/4360K, paused 2ms, total 2ms
08-07 14:36:10.894: I/dalvikvm-heap(2967): Grow heap (frag case) to 3.909MB for 179940-byte allocation
08-07 14:36:10.904: D/dalvikvm(2967): GC_FOR_ALLOC freed 0K, 14% free 3943K/4536K, paused 3ms, total 3ms
08-07 14:36:10.904: D/dalvikvm(2967): GC_FOR_ALLOC freed 86K, 15% free 3857K/4536K, paused 3ms, total 3ms
08-07 14:36:10.904: I/dalvikvm-heap(2967): Grow heap (frag case) to 4.170MB for 362724-byte allocation
08-07 14:36:10.904: D/dalvikvm(2967): GC_FOR_ALLOC freed 0K, 14% free 4211K/4892K, paused 3ms, total 3ms
08-07 14:36:11.874: I/Unity(2967): Progress: 262144 of 175720000 bytes transferred.
08-07 14:36:11.874: I/Unity(2967):
...
08-07 14:40:51.474: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:40:51.504: D/dalvikvm(2967): GC_FOR_ALLOC freed 4387K, 8% free 48578K/52552K, paused 3ms, total 3ms
08-07 14:40:51.534: D/dalvikvm(2967): GC_FOR_ALLOC freed 1405K, 8% free 52059K/56032K, paused 3ms, total 3ms
08-07 14:40:58.134: I/Unity(2967): Progress: 89915392 of 175720000 bytes transferred.
08-07 14:40:58.134: I/Unity(2967):
...
08-07 14:44:54.054: I/Unity(2967): Progress: 163315712 of 175720000 bytes transferred.
08-07 14:44:54.054: I/Unity(2967):
08-07 14:44:54.054: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:44:54.074: D/dalvikvm(2967): GC_FOR_ALLOC freed 8752K, 36% free 32127K/50136K, paused 2ms, total 2ms
08-07 14:44:54.094: D/dalvikvm(2967): GC_FOR_ALLOC freed 1406K, 25% free 37656K/50136K, paused 2ms, total 2ms
08-07 14:44:54.104: D/dalvikvm(2967): GC_FOR_ALLOC freed 1425K, 23% free 39084K/50136K, paused 3ms, total 3ms
08-07 14:45:08.354: I/Unity(2967): Progress: 167510016 of 175720000 bytes transferred.
08-07 14:45:08.354: I/Unity(2967):
08-07 14:45:08.354: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:45:08.374: D/dalvikvm(2967): GC_FOR_ALLOC freed 8762K, 28% free 36228K/50136K, paused 3ms, total 3ms
08-07 14:45:08.394: D/dalvikvm(2967): GC_FOR_ALLOC freed 1405K, 17% free 41757K/50136K, paused 2ms, total 2ms
08-07 14:45:08.404: D/dalvikvm(2967): GC_FOR_ALLOC freed 1425K, 14% free 43185K/50136K, paused 2ms, total 2ms
08-07 14:45:08.404: I/dalvikvm-heap(2967): Grow heap (frag case) to 47.806MB for 5846244-byte allocation
08-07 14:45:08.404: D/dalvikvm(2967): GC_FOR_ALLOC freed 0K, 13% free 48894K/55848K, paused 6ms, total 6ms
08-07 14:45:22.584: I/Unity(2967): Progress: 171704320 of 175720000 bytes transferred.
08-07 14:45:22.584: I/Unity(2967):
08-07 14:45:22.584: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:45:22.624: D/dalvikvm(2967): GC_FOR_ALLOC freed 8761K, 18% free 40329K/48712K, paused 3ms, total 3ms
08-07 14:45:22.644: D/dalvikvm(2967): GC_FOR_ALLOC freed 1405K, 7% free 45683K/48712K, paused 2ms, total 3ms
08-07 14:45:22.654: D/dalvikvm(2967): GC_FOR_ALLOC freed 1425K, 9% free 47111K/51568K, paused 3ms, total 3ms
08-07 14:45:22.654: I/dalvikvm-heap(2967): Grow heap (frag case) to 51.641MB for 5846244-byte allocation
08-07 14:45:22.654: D/dalvikvm(2967): GC_FOR_ALLOC freed 0K, 8% free 52821K/57280K, paused 3ms, total 3ms
08-07 14:45:37.224: I/Unity(2967): Progress: 175720000 of 175720000 bytes transferred.
08-07 14:45:37.224: I/Unity(2967):
08-07 14:45:37.224: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:45:37.244: I/Unity(2967): OnClickUpload::IsCompleted:True IsCanceled:False IsFaulted:False
08-07 14:45:37.244: I/Unity(2967):
08-07 14:45:37.244: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:45:37.244: I/Unity(2967): Finished uploading...
08-07 14:45:37.244: I/Unity(2967):
08-07 14:45:37.244: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:45:37.244: I/Unity(2967): download url = https://firebasestorage.googleapis.com/v0/b/demofirebase2-63523422.appspot.com/o/texts%2Ftest.txt?alt=media&token=e2f250a4-7787-4997-b5c9-f0f78b9a55b7
08-07 14:45:37.244: I/Unity(2967):
08-07 14:45:37.244: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
어쨋든, 업로드 잘 되었다.
직접 파일을 다운로드해서 용량을 확인해 봤다.
정확히 일치한다.
다운로드 받을 때, GetBytesAsync(maxAllowedSize) 함수에 1KB만큼 넣고 시도했다.
결과는 메모리 부족으로 받지 못했다.
08-07 14:49:41.894: I/Unity(2967): OnClickDownload::IsCompleted:True IsCanceled:False IsFaulted:True
08-07 14:49:41.894: I/Unity(2967):
08-07 14:49:41.894: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:49:41.894: I/Unity(2967): System.AggregateException: Exception of type 'System.AggregateException' was thrown.
08-07 14:49:41.894: I/Unity(2967): -----------------
08-07 14:49:41.894: I/Unity(2967): Firebase.Storage.StorageException: An unknown error occurred, please check the HTTP result code and inner exception for server response. ---> System.OutOfMemoryException: Out of memory
08-07 14:49:41.894: I/Unity(2967): at System.IO.MemoryStream.ToArray () [0x00000] in :0
08-07 14:49:41.894: I/Unity(2967): at Firebase.Storage.StorageReference+c__AnonStorey1.<>m__0 (System.IO.Stream s) [0x00000] in :0
08-07 14:49:41.894: I/Unity(2967): at Firebase.Storage.StreamDownloadTask.Run () [0x00000] in :0
08-07 14:49:41.894: I/Unity(2967): --- End of inner exception stack trace ---
08-07 14:49:41.894: I/Unity(2967):
08-07 14:49:41.894: I/Unity(2967): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
이번에는 200MB를 넣고 다시 시도했다.
GC가 지속적으로 찍힌 후, 완료되었다.
08-07 14:54:30.084: D/dalvikvm(3801): GC_FOR_ALLOC freed 487K, 14% free 3439K/3988K, paused 3ms, total 3ms
08-07 14:54:33.464: D/dalvikvm(3801): GC_FOR_ALLOC freed 525K, 15% free 3424K/4012K, paused 2ms, total 2ms
...
08-07 14:54:50.854: D/dalvikvm(3801): GC_FOR_ALLOC freed 512K, 15% free 3422K/4012K, paused 2ms, total 2ms
08-07 14:54:53.674: D/dalvikvm(3801): GC_FOR_ALLOC freed 513K, 15% free 3421K/4012K, paused 2ms, total 2ms
08-07 14:54:54.604: I/Unity(3801): OnClickDownload::IsCompleted:True IsCanceled:False IsFaulted:False
08-07 14:54:54.604: I/Unity(3801):
08-07 14:54:54.604: I/Unity(3801): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:54:54.604: I/Unity(3801): Finished downloading...
08-07 14:54:54.604: I/Unity(3801):
08-07 14:54:54.604: I/Unity(3801): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 14:54:54.614: I/Unity(3801): Contents=175720000
08-07 14:54:54.614: I/Unity(3801):
08-07 14:54:54.614: I/Unity(3801): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
데이터 지우기는 무난히 성공했다.
08-07 12:15:31.501: I/Unity(3656): OnClickDelete::IsCompleted:True IsCanceled:False IsFaulted:False
08-07 12:15:31.501: I/Unity(3656):
08-07 12:15:31.501: I/Unity(3656): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
데이터 지우기를 한번 더 했더니, 없는 파일이라고 예외가 발생했다.
정상적으로 동작하는군.
08-07 12:15:41.061: I/Unity(3656): OnClickDelete::IsCompleted:True IsCanceled:False IsFaulted:True
08-07 12:15:41.061: I/Unity(3656):
08-07 12:15:41.061: I/Unity(3656): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
08-07 12:15:41.061: I/Unity(3656): System.AggregateException: Exception of type 'System.AggregateException' was thrown.
08-07 12:15:41.061: I/Unity(3656): -----------------
08-07 12:15:41.061: I/Unity(3656): Firebase.Storage.StorageException: Object does not exist at location. ---> System.IO.IOException: {
08-07 12:15:41.061: I/Unity(3656): "error": {
08-07 12:15:41.061: I/Unity(3656): "code": 404,
08-07 12:15:41.061: I/Unity(3656): "message": "Not Found. Could not delete object"
08-07 12:15:41.061: I/Unity(3656): }
08-07 12:15:41.061: I/Unity(3656): }
08-07 12:15:41.061: I/Unity(3656): --- End of inner exception stack trace ---
08-07 12:15:41.061: I/Unity(3656):
08-07 12:15:41.061: I/Unity(3656): (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)