SSE Event API
파일 업로드 다이어그램
SSE 도메인 API
- 모디플레닛: https://dev-apiv1.modiplanet.com/event-stream/events (opens in a new tab)
- 모디팩토리: https://dev-apiv1.modifactory.io/event-stream/events (opens in a new tab)
로그인한 계정으로 접근시 sse 연결되며 매20초마다 ping메세지를 전달합니다. 파일 업로드시 EventUploadNotificationMessage 타입으로 메세지 전달합니다. 참고해주세요.
이벤트 Enum 타입
enum EventNotificationType {
"""
파일 업로드 이벤트
"""
FileUploadEvent
}이벤트 메세지 정의
"""
SSE 이벤트 - Notification trigger 메세지
"""
type EventUploadNotificationMessage {
"""
유저 No
"""
userNo: Int!
"""
cdn 주소
"""
cdnUrl: String!
"""
bucket 주소
"""
bucket: String!
"""
key
"""
key: String!
"""
파일 사이즈
"""
fileSize: Int!
"""
source ip
"""
sourceIp: String!
"""
이벤트 타입
"""
eventType: EventNotificationType!
"""
이벤트 발송 타임
"""
eventTime: String!
"""
에러 내용
"""
error: String!
}이벤트 테스트
- 아래와 같이 서버에서 presigned url을 요청하여 받은 url을 받는다.
query PresignedUrlForFileUpload($fileName: String!, $fileType: String!) {
presignedUrlForFileUpload(fileName: $fileName, fileType: $fileType) {
url
}
}- 아래와 같이 header정보를 꼭 설정 해주셔야 업로드시 문제없이 동작합니다.
Content-Type: 컨텐츠의 타입정보 x-amz-acl: S3 객체의 액세스 제어 목록(Access Control List, ACL)을 설정하여 public-read 누구나 읽기 가능하게 설정 x-amz-meta-userno: user의 id또는 profile에서는 userId정보를 넣습니다.
#!/bin/bash
CONTENT_TYPE="images/png"
FILE_NAME="test.png"
curl -X PUT -T "test.png" \
-H "Content-Type: ${CONTENT_TYPE}" \
-H "x-amz-acl: public-read" \
-H "x-amz-meta-userno: 12" \
"presigned url"