[TIL] 230821 ObjectMetaData ๋ž€?

CountryGirlยท2023๋…„ 8์›” 21์ผ
0

TIL

๋ชฉ๋ก ๋ณด๊ธฐ
46/80

๐Ÿ˜Ž ObjectMetaData ๋ž€?

public class ObjectMetadata implements ServerSideEncryptionResult, S3RequesterChargedResult,
        ObjectExpirationResult, ObjectRestoreResult, Cloneable, Serializable
{
	...
}
  • ServerSideEncryptionResult
  • S3RequesterChargedResult
  • ObjectExpirationResult
  • ObjectRestoreResult
  • Cloneable
  • Serializable

๋ฅผ ๊ตฌํ˜„ํ•œ๋‹ค.

Amazon S3์™€ ํ•จ๊ป˜ ์ €์žฅ๋˜๋Š” ๊ฐœ์ฒด ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค.
์‚ฌ์šฉ์ž ์ œ๊ณต ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ์™€ Amazon S3๊ฐ€ ์†ก์ˆ˜์‹ ํ•˜๋Š” ํ‘œ์ค€ HTTP ํ—ค๋” (Content-Length, ETag, Content-MD5 ๋“ฑ) ์ด ํฌํ•จ๋œ๋‹ค.

๋ผ๊ณ  ์“ฐ์—ฌ ์žˆ์ง€๋งŒ.. ์ด๊ฒŒ ๋ฌด์Šจ ๋ง์ธ์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค.

์ž, ์ด๊ฒŒ ๋ฌด์Šจ ๋ง์ด๋ƒ๋ฉด!

<ObjectMetaData ๋ž€?>
Amazon S3์— ์—…๋กœ๋“œ๋˜๋Š” ํŒŒ์ผ ๋˜๋Š” ๊ฐ์ฒด์™€ ๊ด€๋ จ๋œ ์ •๋ณด(ํŒŒ์ผ์˜ ์œ ํ˜•, ํฌ๊ธฐ, ๋ฒ„์ „ ๋“ฑ๊ณผ ๊ฐ™์€ ์ •๋ณด)

ObjectMetaData์— ์‚ฌ์šฉ์ž๊ฐ€ ์ •์˜ํ•œ ์ถ”๊ฐ€์ ์ธ ์ •๋ณด๋ฅผ ํฌํ•จํ•  ์ˆ˜ ์žˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ํŒŒ์ผ์˜ ์ž‘์„ฑ์ž, ์„ค๋ช…, ํƒœ๊ทธ ๋˜๋Š” ์‚ฌ์šฉ์ž ์ง€์ • ๋ ˆ์ด๋ธ”๊ณผ ๊ฐ™์€ ์ •๋ณด

<Amazon S3 ์™€ ํด๋ผ์ด์–ธํŠธ ๊ฐ„์— ํŒŒ์ผ ์ „์†ก์— ์‚ฌ์šฉ๋˜๋Š” ํ‘œ์ค€ HTTP ํ—ค๋”>

- Content-Length: ํŒŒ์ผ์˜ ํฌ๊ธฐ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ํ—ค๋”. ํŒŒ์ผ์˜ ๋ฐ”์ดํŠธ ์ˆ˜๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค.
- ETag: ํŒŒ์ผ์˜ ๋ฒ„์ „์„ ์‹๋ณ„ํ•˜๋Š” ํƒœ๊ทธ
- Content-MD5: ํŒŒ์ผ์˜ ๋ฌด๊ฒฐ์„ฑ์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•œ ํŒŒ์ผ ๋ฐ์ดํ„ฐ์˜ MD5 ํ•ด์‹œ๊ฐ’

(ํ‘œ์ค€ HTTP ํ—ค๋”๋Š” ํŒŒ์ผ ์ „์†ก ๋ฐ ๊ฐ์ฒด ๊ด€๋ฆฌ ๊ณผ์ •์—์„œ ์ค‘์š”ํ•œ ์—ญํ• ์„ ํ•œ๋‹ค.)

์‚ฌ์šฉ์ž๊ฐ€ ์ œ๊ณตํ•œ ์‚ฌ์šฉ์ž ์ •์˜ ์ •๋ณด์™€ ํ•จ๊ป˜ ํ‘œ์ค€ HTTP ํ—ค๋” ์ •๋ณด๋ฅผ ํฌํ•จํ•˜์—ฌ ๊ฐ์ฒด๋ฅผ ์„ค๋ช…ํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š”๋ฐ ์‚ฌ์šฉ

๐Ÿ› ๏ธ ์‚ฌ์šฉ ๋ฐฉ๋ฒ•

1. ObjectMetadata ๊ฐ์ฒด ์ƒ์„ฑ

: ObjectMetadata ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ํ•„์š”ํ•œ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ์„ค์ •

import com.amazonaws.services.s3.model.ObjectMetadata;

ObjectMetadata objectMetadata = new ObjectMetadata();

2. S3 ๊ฐ์ฒด ์—…๋กœ๋“œ ์‹œ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ์‚ฌ์šฉ

: S3 ๋ฒ„ํ‚ท์— ๊ฐ์ฒด๋ฅผ ์—…๋กœ๋“œํ•  ๋•Œ ObjectMetadata ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ํ•จ๊ป˜ ์—…๋กœ๋“œ

objectMetadata.setContentLength(multipartFile.getSize());
objectMetadata.setContentType(multipartFile.getContentType());

๐Ÿ“‚ ObjectMetadata๋ฅผ ์ด์šฉํ•œ ํŒŒ์ผ ์—…๋กœ๋“œ

ObjectMetadata๋ฅผ ์ด์šฉํ•œ ํŒŒ์ผ ์—…๋กœ๋“œ


โœ… REFERENCE

ObjectMetadata (AWS SDK)

profile
๐Ÿ’ป๐ŸŒพ์‹œ๊ณจ์†Œ๋…€์˜ ์—‰๋ง์ง•์ฐฝ ๊ฐœ๋ฐœ ์„ฑ์žฅ์ผ์ง€๐ŸŒพ๐Ÿ’ป (2023.05.23 ~)

0๊ฐœ์˜ ๋Œ“๊ธ€