I have some files in IBM cloud object storage bucket. I need to download those files to my local storage using a serverless function. I tried it using Python but encountering a problem. And I also wanted to ask where to provide the path of local storage folder.
It will be a great help if some code will be added. Thank you.
I tried this :
import ibm_boto3
from ibm_botocore.client import Config
import os,os.path
import pathlib
import glob
import requests
cos = ibm_boto3.client(service_name='s3',
ibm_api_key_id='my-api-key',
ibm_service_instance_id='id-from-service-credential',
config=Config(signature_version='oauth'),
endpoint_url='https://s3.eu-gb.cloud-object-storage.appdomain.cloud')
try:
res = cos.download_file(Key='abc.txt',Bucket='cloud-college-bucket0',Filename='abc.txt')
except Exception as e:
print(Exception, e)
else:
print('File Downloaded')
Error encountered is :
"error": "File Downloaded\n/usr/local/lib/python3.7/site-packages/ibm_botocore/vendored/requests/api.py:67: DeprecationWarning: You are using the post() function from 'ibm_botocore.vendored.requests'. This is not a public API in ibm_botocore and will be removed in the future. Additionally, this version of requests is out of date. We recommend you install the requests package, 'import requests' directly, and use the requests.post() function instead.\n DeprecationWarning\nTraceback (most recent call last):\n File \"/action/1/src/exec__.py\", line 43, in \n from main__ import main as main\nImportError: cannot import name 'main' from 'main__' (/action/1/src/main__.py)\n" }