Skip to content

Commit

Permalink
Merge pull request #39 from juanpablo-is/master
Browse files Browse the repository at this point in the history
Fix: Update uploading ticket image
  • Loading branch information
Damian-Zsiros-Prog authored Jul 7, 2023
2 parents 8106395 + b015969 commit 08a09fa
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions src/components/Ticket/Ticket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,33 @@ export default function Ticket({}) {

const { data, error } = await supabase.storage
.from('Tickets Images')
.getPublicUrl(
.download(
`Ticket-de-@${userInfo.username_github}.png`
)

if (error) {
console.error(
'Error al verificar la existencia de la imagen:',
error.message
)
} else {
if (data.publicUrl) {
// La imagen no existe, realizar la subida
const response = await fetch(imgData)
const blob = await response.blob()
if (error && error.message === "The resource was not found") {
// La imagen no existe, realizar la subida
const response = await fetch(imgData)
const blob = await response.blob()

const {
data: uploadData,
error: uploadError,
} = await supabase.storage
.from('Tickets Images')
.upload(
`Ticket-de-@${userInfo.username_github}.png`,
blob
)
const {
data: uploadData,
error: uploadError,
} = await supabase.storage
.from('Tickets Images')
.upload(
`Ticket-de-@${userInfo.username_github}.png`,
blob
)

if (uploadError) {
console.error(
'Error al subir la imagen:',
uploadError.message
)
}
} else {
if (uploadError) {
console.error(
'Error al subir la imagen:',
uploadError.message
)
}
} else {
if (data) {
console.log(
'La imagen ya existe en el almacenamiento de Supabase.'
)
Expand Down

0 comments on commit 08a09fa

Please sign in to comment.