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

質問編集履歴

6

記載ミス

2021/01/17 00:50

投稿

aiai8976
aiai8976

スコア112

title CHANGED
File without changes
body CHANGED
@@ -45,7 +45,7 @@
45
45
  ####追加変更
46
46
  ```python
47
47
  # blob.upload_from_file(io.BytesIO(file).read(), content_type=content_type)
48
- bstream = io.ByteIO()
48
+ bstream = io.BytesIO()
49
49
  file.save(bstream)
50
50
  bstream.seek(0)
51
51
  blob.upload_from_file(bstream.read(), content_type=content_type)
@@ -53,5 +53,5 @@
53
53
 
54
54
  結果
55
55
  ```
56
- AttributeError: module 'io' has no attribute 'ByteIO'
56
+ AttributeError: 'bytes' object has no attribute 'tell'
57
57
  ```

5

記載ミス

2021/01/17 00:49

投稿

aiai8976
aiai8976

スコア112

title CHANGED
File without changes
body CHANGED
@@ -53,5 +53,5 @@
53
53
 
54
54
  結果
55
55
  ```
56
- TypeError: expected str, bytes or os.PathLike object, not NoneType
56
+ AttributeError: module 'io' has no attribute 'ByteIO'
57
57
  ```

4

質問の解答

2021/01/17 00:38

投稿

aiai8976
aiai8976

スコア112

title CHANGED
File without changes
body CHANGED
@@ -48,7 +48,7 @@
48
48
  bstream = io.ByteIO()
49
49
  file.save(bstream)
50
50
  bstream.seek(0)
51
- blob.upload_from_file(io.BytesIO(file).read(), content_type=content_type)
51
+ blob.upload_from_file(bstream.read(), content_type=content_type)
52
52
  ```
53
53
 
54
54
  結果

3

質問の解答

2021/01/16 23:58

投稿

aiai8976
aiai8976

スコア112

title CHANGED
File without changes
body CHANGED
@@ -36,17 +36,22 @@
36
36
  ```
37
37
 
38
38
  ### 試したこと
39
- io.BytesIO(file).read()に変更
39
+ ####io.BytesIO(file).read()に変更
40
40
 
41
41
  ```
42
42
  TypeError: a bytes-like object is required, not 'FileStorage'
43
43
  ```
44
44
 
45
- 追加変更
45
+ ####追加変更
46
46
  ```python
47
47
  # blob.upload_from_file(io.BytesIO(file).read(), content_type=content_type)
48
48
  bstream = io.ByteIO()
49
49
  file.save(bstream)
50
50
  bstream.seek(0)
51
51
  blob.upload_from_file(io.BytesIO(file).read(), content_type=content_type)
52
+ ```
53
+
54
+ 結果
55
+ ```
56
+ TypeError: expected str, bytes or os.PathLike object, not NoneType
52
57
  ```

2

質問の解答

2021/01/14 11:04

投稿

aiai8976
aiai8976

スコア112

title CHANGED
File without changes
body CHANGED
@@ -40,4 +40,13 @@
40
40
 
41
41
  ```
42
42
  TypeError: a bytes-like object is required, not 'FileStorage'
43
+ ```
44
+
45
+ 追加変更
46
+ ```python
47
+ # blob.upload_from_file(io.BytesIO(file).read(), content_type=content_type)
48
+ bstream = io.ByteIO()
49
+ file.save(bstream)
50
+ bstream.seek(0)
51
+ blob.upload_from_file(io.BytesIO(file).read(), content_type=content_type)
43
52
  ```

1

質問の解答

2021/01/14 11:03

投稿

aiai8976
aiai8976

スコア112

title CHANGED
File without changes
body CHANGED
@@ -33,4 +33,11 @@
33
33
  blob.upload_from_file(file.read(), content_type=content_type)
34
34
  blob.make_public()
35
35
  return blob.public_url
36
+ ```
37
+
38
+ ### 試したこと
39
+ io.BytesIO(file).read()に変更
40
+
41
+ ```
42
+ TypeError: a bytes-like object is required, not 'FileStorage'
36
43
  ```