|
import requests |
|
from google.cloud import storage |
|
|
|
def upload_file_to_gcs(file_url, bucket_name, object_name): |
|
|
|
response = requests.get(file_url) |
|
file_content = response.content |
|
|
|
|
|
storage_client = storage.Client() |
|
|
|
|
|
bucket = storage_client.bucket(bucket_name) |
|
|
|
|
|
blob = bucket.blob(object_name) |
|
blob.upload_from_string(file_content) |
|
|
|
print(f"File uploaded to {bucket_name}/{object_name}") |
|
|
|
|
|
bucket_name = 'your-bucket-name' |
|
file_url = 'https://dkstatics-public.digikala.com/digikala-products/26c6255b595c4aac4c30f7fa6644c1a726b70972_1694005299.jpg' |
|
object_name = '1694005299.jpg' |
|
|
|
upload_file_to_gcs(file_url, bucket_name, object_name) |