How to download file from google cloud bucket?
up vote
0
down vote
favorite
I just received an access to bucket gs://asdasdasdasdd-sadasdasd on Google Cloud Storage with files for test exercise.
They said I have an access for my google account.
But how am I supposed to download file rom there in python? With which credentails?
I created service account and downloaded json file with my credentials, but I am forbidden to download files form the bucket.
How should I process further?
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from io import BytesIO
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="account.json"
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.get_bucket('asdasdasdasdd-sadasdasd')
blob = bucket.blob('streams/2017/09/09/allcountries')
path = "gs://asdasdasdasdd-sadasdasd/streams/2017/09/09/allcountries.csv"
df = pd.read_csv(path)
I am able to download file with gsutil
but I need to do the same with python. Someway I need to verify my email becuase I was granted to download file on my google email.
python google-cloud-platform cloud google-cloud-storage
add a comment |
up vote
0
down vote
favorite
I just received an access to bucket gs://asdasdasdasdd-sadasdasd on Google Cloud Storage with files for test exercise.
They said I have an access for my google account.
But how am I supposed to download file rom there in python? With which credentails?
I created service account and downloaded json file with my credentials, but I am forbidden to download files form the bucket.
How should I process further?
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from io import BytesIO
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="account.json"
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.get_bucket('asdasdasdasdd-sadasdasd')
blob = bucket.blob('streams/2017/09/09/allcountries')
path = "gs://asdasdasdasdd-sadasdasd/streams/2017/09/09/allcountries.csv"
df = pd.read_csv(path)
I am able to download file with gsutil
but I need to do the same with python. Someway I need to verify my email becuase I was granted to download file on my google email.
python google-cloud-platform cloud google-cloud-storage
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I just received an access to bucket gs://asdasdasdasdd-sadasdasd on Google Cloud Storage with files for test exercise.
They said I have an access for my google account.
But how am I supposed to download file rom there in python? With which credentails?
I created service account and downloaded json file with my credentials, but I am forbidden to download files form the bucket.
How should I process further?
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from io import BytesIO
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="account.json"
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.get_bucket('asdasdasdasdd-sadasdasd')
blob = bucket.blob('streams/2017/09/09/allcountries')
path = "gs://asdasdasdasdd-sadasdasd/streams/2017/09/09/allcountries.csv"
df = pd.read_csv(path)
I am able to download file with gsutil
but I need to do the same with python. Someway I need to verify my email becuase I was granted to download file on my google email.
python google-cloud-platform cloud google-cloud-storage
I just received an access to bucket gs://asdasdasdasdd-sadasdasd on Google Cloud Storage with files for test exercise.
They said I have an access for my google account.
But how am I supposed to download file rom there in python? With which credentails?
I created service account and downloaded json file with my credentials, but I am forbidden to download files form the bucket.
How should I process further?
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from io import BytesIO
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="account.json"
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.get_bucket('asdasdasdasdd-sadasdasd')
blob = bucket.blob('streams/2017/09/09/allcountries')
path = "gs://asdasdasdasdd-sadasdasd/streams/2017/09/09/allcountries.csv"
df = pd.read_csv(path)
I am able to download file with gsutil
but I need to do the same with python. Someway I need to verify my email becuase I was granted to download file on my google email.
python google-cloud-platform cloud google-cloud-storage
python google-cloud-platform cloud google-cloud-storage
edited Nov 10 at 19:40
asked Nov 9 at 20:15
paveltr
197417
197417
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
I assume you were granted a role to access the bucket. If so, you do not need the service account key (.json file), as this key has been generated by you, therefore it is granting permissions to the resources under your project and not someone else's.
Make sure the role you were given is roles/storage.admin
as this is the role needed to download files from the specified bucket.
Another option would be to indeed use a service account key, containing the same role, but it has to be given to you by the owner of the bucket.
Lastly, I tried your code and came across an error once I was able to connect to the bucket. If you encounter an IOError telling you the file does not exist, take a look at this post for a possible solution.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I assume you were granted a role to access the bucket. If so, you do not need the service account key (.json file), as this key has been generated by you, therefore it is granting permissions to the resources under your project and not someone else's.
Make sure the role you were given is roles/storage.admin
as this is the role needed to download files from the specified bucket.
Another option would be to indeed use a service account key, containing the same role, but it has to be given to you by the owner of the bucket.
Lastly, I tried your code and came across an error once I was able to connect to the bucket. If you encounter an IOError telling you the file does not exist, take a look at this post for a possible solution.
add a comment |
up vote
0
down vote
I assume you were granted a role to access the bucket. If so, you do not need the service account key (.json file), as this key has been generated by you, therefore it is granting permissions to the resources under your project and not someone else's.
Make sure the role you were given is roles/storage.admin
as this is the role needed to download files from the specified bucket.
Another option would be to indeed use a service account key, containing the same role, but it has to be given to you by the owner of the bucket.
Lastly, I tried your code and came across an error once I was able to connect to the bucket. If you encounter an IOError telling you the file does not exist, take a look at this post for a possible solution.
add a comment |
up vote
0
down vote
up vote
0
down vote
I assume you were granted a role to access the bucket. If so, you do not need the service account key (.json file), as this key has been generated by you, therefore it is granting permissions to the resources under your project and not someone else's.
Make sure the role you were given is roles/storage.admin
as this is the role needed to download files from the specified bucket.
Another option would be to indeed use a service account key, containing the same role, but it has to be given to you by the owner of the bucket.
Lastly, I tried your code and came across an error once I was able to connect to the bucket. If you encounter an IOError telling you the file does not exist, take a look at this post for a possible solution.
I assume you were granted a role to access the bucket. If so, you do not need the service account key (.json file), as this key has been generated by you, therefore it is granting permissions to the resources under your project and not someone else's.
Make sure the role you were given is roles/storage.admin
as this is the role needed to download files from the specified bucket.
Another option would be to indeed use a service account key, containing the same role, but it has to be given to you by the owner of the bucket.
Lastly, I tried your code and came across an error once I was able to connect to the bucket. If you encounter an IOError telling you the file does not exist, take a look at this post for a possible solution.
answered Nov 10 at 13:47
Maxim
255
255
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232733%2fhow-to-download-file-from-google-cloud-bucket%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown