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
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
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
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
Hi,
is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
I have a super simple question about elixir - how would I take a file like this
foo
bar
baz
and output a new file that enumerates th...
New
Other popular topics
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Hello, how can I check the Phoenix version ?
Thanks !
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









