sobojack
Google cloud upload fails in dev env, but works locally
Hello Friends, I have a phoenix app up in GCP k8s in a dev env. I have an image uploader that has been working in the past and suddenly stopped working. I am making a request to upload an image to a google cloud bucket, this is the code
def upload_image_file(image_file_struct, path) do
{:ok, token} = Goth.Token.for_scope("https://www.googleapis.com/auth/cloud-platform")
bucket = Application.get_env(:beswick, Beswick)[:image_bucket]
conn = GoogleApi.Storage.V1.Connection.new(token.token)
case GoogleApi.Storage.V1.Api.Objects.storage_objects_insert_simple(
conn,
Application.get_env(:beswick, Beswick)[:image_bucket],
"multipart",
%{
name: "cc_catalogs/Beswick/#{path}/#{Path.basename(image_file_struct.filename)}",
contentType: "image/jpeg"
},
image_file_struct.path
) do
{:ok, result} ->
IO.inspect("made it this far")
# changeset
# |> cast(%{image_url: image_file_struct.filename}, [
# :image_url
# ])
{:ok, image_file_struct.filename}
error ->
IO.inspect("FILE UPLOAD ERROR")
IO.inspect(error)
{:error, error}
end
end
When I call the storage_objects_insert_simple The connections terminates and returns a 500.
INFO 2024-04-09T01:41:01.146749942Z [resource.labels.containerName: product-manager] 01:41:01.144 [info] Sent 500 in 1245ms
INFO 2024-04-09T01:41:01.148383022Z [resource.labels.containerName: product-manager] 01:41:01.144 [error] #PID<0.3390.0> running BeswickWeb.Endpoint (connection #PID<0.3197.0>, stream id 3) terminated
I am not sure why, this code runs locally but does not errors in dev. Any help would be greatly appreciated
Marked As Solved
D4no0
I suspect you updated OTP version to 25+ ?
Try to downgrade to the previous used version (or the version you are using on dev).
As for why this might happen, starting from OTP-25 this functionality was introduced: Erlang/OTP 25 Highlights - Erlang/OTP
1
Also Liked
benwilson512
Author of Craft GraphQL APIs in Elixir with Absinthe
Hi, can you provide the full error stacktrace?
1
Popular in Questions
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Other popular topics
Manning 2016 Halloween weekend sale via Deal of the Day
Friday, October 28 - Half off all MEAPs - code WM102816LT
Saturday, October 29 ...
New
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
I would like to know what is the best IDE for elixir development?
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New







