-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
オブジェクトストレージの実装 #17
オブジェクトストレージの実装 #17
Conversation
Image(年賀状のスタンプ)は多分ファイル名が必要になるからいるかも (追記)いらんか |
pub fn new(bucket: &Bucket) -> Self { | ||
Self(bucket.clone()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CardRepositoryConfig
と同じようなやつが欲しい
struct Config {
pub bucket_name: String,
pub region: String,
pub credentials: String, // ?
}
repository/src/image.rs
Outdated
|
||
#[async_trait::async_trait] | ||
pub trait ImageRepository { | ||
async fn save_png(&self, card_id: Uuid, content: &[u8]) -> Result<(), RepositoryError>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes::Bytes
がDeref<Target=[u8]>
持ってるのでそちらを
repository/src/image.rs
Outdated
&self, | ||
id: Uuid, | ||
mime_type: &str, | ||
content: &[u8], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes::Bytes
repository/src/image.rs
Outdated
} | ||
async fn delete_svg(&self, id: Uuid) -> Result<(), RepositoryError> { | ||
let bucket = &self.0; | ||
let key = id.to_string() + ".svg"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uuid::Uuid
はDisplay
実装してるのでformat!
使えばちょっといい感じになるかも?まあこのままでも全然
@@ -103,7 +101,7 @@ impl CardRepository for CardRepositoryImpl { | |||
} | |||
} | |||
|
|||
async fn save_card(&self, params: &SaveCardParams) -> Result<(), DbErr> { | |||
async fn save_card(&self, params: &SaveCardParams) -> Result<(), RepositoryError> { | |||
// TODO: 画像の保存 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO消せるはず?
repository/src/error.rs
Outdated
#[error("NotFound")] | ||
NotFound, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NotFound
消えて欲しい
delete
のとこで使ってそう
repository/src/image.rs
Outdated
match image { | ||
Ok(x) => Ok(Some(( | ||
x.headers().get("content-type").unwrap().to_string(), | ||
x.to_vec(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
バイナリデータはbytes::Bytes
で揃えたいので、Bytes::from(x.to_vec())
とかで 🙏
書き忘れてた、compose.yamlにs3のモックが欲しい |
bucketが自動で作成されないので手動で作成する
|
書いてから思ったけどmysqlにid保存する必要なかったかも