teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

ファイルパス生成部分の訂正

2020/10/06 15:36

投稿

chimo
chimo

スコア55

title CHANGED
File without changes
body CHANGED
@@ -7,7 +7,18 @@
7
7
  viewModel.uploadFile(fileName, repository = StorageRepository())
8
8
  }
9
9
  ```
10
+ fileNameは別のActivityで以下のように作成してます
11
+ ```
12
+ private fun makeSaveFile(): String {
13
+ val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.JAPAN).format(Date())
14
+ val folder = this.activity?.getExternalFilesDir(null)
15
+ val fileName = "sharephoto" + timeStamp
16
+ val file = File(folder, fileName)
17
+ return file.absolutePath
18
+ }
19
+ ```
10
20
 
21
+
11
22
  uploadFileメソッドは【ViewModel.kt】で以下のように定義しています
12
23
  ```
13
24
  class ViewModel : ViewModel() {