Neophen
External uploads custom metadata
Is there a way to add custom meta data back to entry after the upload?
import { UploadClient } from '@uploadcare/upload-client'
const client = new UploadClient({ publicKey: "publicKey" })
const Uploadcare = (entries, onViewError) => {
const uploadEntry = makeEntryUploader(onViewError)
entries.forEach(uploadEntry)
}
const makeEntryUploader = (onViewError) => async (entry) => {
const onProgress = ({ isComputable, value }) => {
if (isComputable) {
let percent = Math.round(value * 100)
if (percent < 100) { entry.progress(percent) }
}
}
const abortController = new AbortController()
onViewError(() => abortController.abort())
const result = await client.uploadFile(entry.file, {
onProgress,
signal: abortController.signal,
})
// How to add the data to the entry?
entry.meta = {
...entry.meta,
// This doesn't work:
uploadcare: result
}
entry.progress(100)
}
const uploaders = {
Uploadcare,
}
export default uploaders
I have this in the live view:
defp presign_upload(entry, socket) do
meta = %{uploader: "Uploadcare"}
{:ok, meta, socket}
end
But I only get the url and stuff in the response from the await client.uploadFile(entry.file, {
Has anyone ran into this? Do I need move the uploading to the server side to get the required data?
Marked As Solved
Neophen
For anyone else interested this is the current solution i arrived at.
It’s a hack with the least amount of indirection that i could come up with.
0
Popular in Questions
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
In templates/appointment/index.html.eex:
<%= for appointment <- @appointments do %>
<tr>
<td><%= appoi...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
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
Other popular topics
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
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 wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something…
Haskell reminds me of Java, and e...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









