공학/지능형 임베디드

Google Cloud

traveler98 2023. 6. 8. 08:58

Google Cloud Platform(GCP)은 Google이 제공하는 클라우드 컴퓨팅 서비스 모음입니다. GCP는 일반적으로 다양한 데이터 관리, 머신러닝, 인공지능, 컴퓨팅, 네트워킹 및 스토리지 서비스를 제공합니다.

GCP의 주요 서비스 중 일부는 다음과 같습니다:
- Google Compute Engine: 가상머신을 호스팅하는 인프라스트럭처-as-a-service (IaaS).
- Google Kubernetes Engine: 컨테이너화된 애플리케이션을 위한 오케스트레이션 서비스.
- Google App Engine: 개발자가 서버 관리 걱정 없이 애플리케이션을 배포할 수 있게 해주는 platform-as-a-service (PaaS).
- Google Cloud Storage: 데이터를 저장하고 액세스하는데 사용되는 객체 스토리지 서비스.
- Google BigQuery: 대규모 데이터셋에 대해 빠른 SQL 쿼리를 실행할 수 있는 완전 관리형 데이터 웨어하우스.


다음은 Python을 사용하여 Google Cloud Storage에 파일을 업로드하는 예시 코드입니다.

```python
from google.cloud import storage

def upload_to_bucket(blob_name, path_to_file, bucket_name):
    """ Upload data to a bucket"""

    # Explicitly use service account credentials by specifying the private key file.
    storage_client = storage.Client.from_service_account_json('path_to_service_account_file.json')

    # Get GCS bucket
    bucket = storage_client.get_bucket(bucket_name)

    # Create a new blob and upload the file
    blob = bucket.blob(blob_name)
    blob.upload_from_filename(path_to_file)

    return True

upload_to_bucket('my-test-blob', '/path/to/my/file', 'my-bucket')
```

이 코드는 Google Cloud의 서비스 계정 키 파일을 사용하여 Google Cloud Storage 클라이언트를 인증하고, 지정된 버킷에 파일을 업로드합니다. 

참고로, 실제 코드에서는 'path_to_service_account_file.json', '/path/to/my/file', 그리고 'my-bucket'은 실제 파일 경로와 버킷 이름으로 대체해야 합니다. 또한, 이 코드를 실행하기 전에 'google-cloud-storage' 라이브러리를 설치해야 합니다. (pip install google-cloud-storage)

'공학 > 지능형 임베디드' 카테고리의 다른 글

MQTT  (0) 2023.06.08
Google Cloud를 Mysql에 연동  (0) 2023.06.08
SQLite란?  (0) 2023.06.08
Local Database  (0) 2023.06.08
ThingSpeak 사용 예시 코드  (0) 2023.06.08