Skip to content

Conversation

@choonkeat
Copy link
Collaborator

  • pulls object from backend and send the bytes directly out via http.ResponseWriter (no processing)
  • 404 if object is not found in backend

unfortunately, some lambda platforms (e.g. google cloud) gives very specific url

i.e.

https://xyz.cloudfunctions.net/attache

will hit your lambda function, but

https://xyz.cloudfunctions.net/attache/abc

will NOT hit your lambda function; returns 404

so in order for us to retrieve images like

https://xyz.cloudfunctions.net/attache/resize/100x/987654321.gif

we'd need to specify instead as,

https://xyz.cloudfunctions.net/attache?resize/100x/987654321.gif

and do some strings.TrimPrefix(r.URL.RequestURI(), "/attache?") to obtain the "resize/100x/987654321.gif"

Would have preferred io.Reader, but s3.PutObjectInput ugh
Smaller interfaces allows the function to be used by more types
So we have to find another way to introduce paths
http.Error(w, fullpath, http.StatusNotFound)
return
}
io.Copy(w, stream)
Copy link
Collaborator Author

@choonkeat choonkeat Dec 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE that we didn't set Content-Type response header yet

  1. We can sniff again and set the Content-Type (oh noes, gotta read 512 bytes and juggle rewinding the io.Reader...)
  2. OR better, when we store the file into backend (e.g. s3, google cloud storage, ...) we should've put the sniffed content type as metadata (e.g. see PutObjectInput.Metadata. So that when we perform download, we can resupply the Content-Type without re-sniffing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants