AWS S3 λ₯Ό μ΄μ©ν΄, μλ²μμ μ½μμμλλ‘ μ΄λ―Έμ§λ₯Ό μ λ‘λνκ³ μ νμλ€.
μΌλ¨ AWS S3 μ λ²ν·μ μμ±νμ¬, test ν΄ λ³΄μλ€.
β μμ±ν λ, μλμ μ΄λ―Έμ§μ κ°μ΄ 체ν¬λ°μ€λ₯Ό ν΄μ νμ¬, νΌλΈλ¦μΌλ‘ λλ €μ ν
μ€νΈλ₯Ό ν΄λ³΄μλ€.
κ·Έ ν, κΈ°λ³Έμ μΈ μ μ± μ€μ μ ν΄μ€λ€.
{
"Version": "2012-10-17",
"Id": "Policy1692011436732",
"Statement": [
{
"Sid": "Stmt1692011388256",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::fm2023-player-images/*"
}
]
}
-> μΆνμ, μ λ‘λλ₯Ό νμ©νλ μμ΄νΌμ μ½μ΄μ¬μμλ μμ΄λλ₯Ό λΆλ¦¬ν΄μ€ μκ°μ΄λ€.
μ΄μ , μ¬κΈ°μ μ΄λ―Έμ§λ₯Ό μ λ‘λν΄μΌνλλ°,,, κ²μλ΄μ λͺ¨λ μ μ λ° μ½μΉμ μ΄λ―Έμ§κ° λ΄κΈ΄ νμΌμ μμ§λ§, λλ λ΄κ° κ°μ Έμ¬ λ°μ΄ν°μ μ μ μ¬μ§λ§ 골λΌμ κ°μ ΈμμΌ μ©λμ μ€μΌ μ μλ€.
μΌλ¨, κ°λ¨νκ² μ€λͺ νλ©΄, μ΄μ λ³νν SQL λ¬Έ 94κ°μ νμΌμ JSON νμΌλ‘ λ³ννμ¬ ν΄λΉ νμΌκ³Ό μΌμΉνλ μ΄λ―Έμ§νμΌλ§ λ°λ‘ λ€λ₯Έ ν΄λμ μ μ₯νλ €κ³ νλ€.
ChatGPT μ ꡬκΈμ μ λμνμ¬, μλμ κ°μ λ‘μ§μ ꡬννμλ€.
import os
import shutil
import json
# JSON νμΌμ κ²½λ‘λ₯Ό μ§μ ν©λλ€.
json_file_path = "C:/Users/μ΄κ΄λ ¬/Desktop/test/1.json"
# μ¬μ§λ€μ΄ μλ ν΄λμ 볡μ¬νκ±°λ μ΄λν λμ ν΄λλ₯Ό μ§μ ν©λλ€.
source_folder = "C:/Users/μ΄κ΄λ ¬/Downloads/image/sortitoutsi/faces"
destination_folder = "C:/Users/μ΄κ΄λ ¬/Downloads/image/sortitoutsi/players"
# ν΄λκ° μμΌλ©΄ μμ±ν©λλ€.
if not os.path.exists(destination_folder):
os.makedirs(destination_folder)
# JSON νμΌμ λΆλ¬μ΅λλ€.
with open(json_file_path, 'r', encoding='utf-8-sig') as json_file:
data = json.load(json_file)
# λͺ¨λ νλͺ©μ μννλ©΄μ νμΌλͺ
μ νμΈνκ³ λ³΅μ¬ λλ μ΄λν©λλ€.
for item in data:
if 'ID' in item:
filename = item['ID'] + ".png"
source_path = os.path.join(source_folder, filename)
destination_path = os.path.join(destination_folder, filename)
# νμΌμ΄ μλ³Έ ν΄λμ μ‘΄μ¬νλ κ²½μ° λ³΅μ¬ν©λλ€.
if os.path.exists(source_path):
shutil.copy2(source_path, destination_path)
print("μμ
μλ£!")
HTML to JSON μΌλ‘ λ³νν νμΌμ 1.json νμΌμ 볡μ¬λΆμ¬λ£κΈ° ν΄μ€λ€.
κ·Έν, νμ΄μ¬ μ½λλ₯Ό μ€ννμ¬ μ΄λ―Έμ§ νμΌμ μ§μ ν ν΄λλ‘ λ³΅μ¬νλ€.
μ΄ μμ μ 94λ² λ°λ³΅ν΄ μ£Όμλ€...
볡μ¬ν ν΄λλ₯Ό S3 λ²ν·μ μ
λ‘λνλ€.