Skip to content

Commit

Permalink
hopefully fix downloading images from image blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Jun 21, 2021
1 parent 734d5bc commit e11d5a3
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 167 deletions.
9 changes: 5 additions & 4 deletions block.go
Expand Up @@ -78,10 +78,10 @@ const (
// BlockTweet is embedded gist block
BlockTweet = "tweet"
// BlockVideo is youtube video embed
BlockVideo = "video"
BlockCopyIndicator = "copy_indicator"
BlockVideo = "video"
BlockCopyIndicator = "copy_indicator"
BlockLinkToCollection = "link_to_collection"
BlockMiro = "miro"
BlockMiro = "miro"
)

// FormatBookmark describes format for BlockBookmark
Expand Down Expand Up @@ -318,6 +318,7 @@ type Block struct {
// not always available
Permissions *[]Permission `json:"permissions,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
SpaceID string `json:"space_id"`
// type of the block e.g. TypeText, TypePage etc.
Type string `json:"type"`
// blocks are versioned
Expand Down Expand Up @@ -545,7 +546,7 @@ func parseProperties(block *Block) error {
}

if block.Source != "" && block.IsImage() {
block.ImageURL = maybeProxyImageURL(block.Source)
block.ImageURL = maybeProxyImageURL(block.Source, block.ID, block.ParentTable)
}

// for BlockCode
Expand Down
7 changes: 4 additions & 3 deletions caching_downloader/caching_downloader.go
Expand Up @@ -448,8 +448,9 @@ func GetCacheFileNameFromURL(uri string) string {
return filepath.Join("files", name)
}

// DownloadFile downloads a file, caching in the cache
func (d *Downloader) DownloadFile(uri string, blockID string) (*notionapi.DownloadFileResponse, error) {
// DownloadFile downloads a file refered by block with a given blockID and a parent table
// we cache the file
func (d *Downloader) DownloadFile(uri string, blockID string, parentTable string) (*notionapi.DownloadFileResponse, error) {
//fmt.Printf("Downloader.DownloadFile('%s'\n", uri)
cacheFileName := GetCacheFileNameFromURL(uri)
var data []byte
Expand All @@ -476,7 +477,7 @@ func (d *Downloader) DownloadFile(uri string, blockID string) (*notionapi.Downlo
}

timeStart := time.Now()
res, err := d.Client.DownloadFile(uri, blockID)
res, err := d.Client.DownloadFile(uri, blockID, parentTable)
if err != nil {
d.emitError("Downloader.DownloadFile(): failed to download %s, error: %s", uri, err)
return nil, err
Expand Down
4 changes: 4 additions & 0 deletions do/main.go
Expand Up @@ -192,6 +192,10 @@ func main() {

must(os.MkdirAll(cacheDir, 0755))

if false {
flgPreviewHTML = "da0b358c21ab4ac6b5c0f7154b2ecadc"
}

if false {
testDownloadFile()
return
Expand Down
8 changes: 4 additions & 4 deletions do/tests_adhoc.go
Expand Up @@ -23,8 +23,8 @@ func testDownloadFile() {
DebugLog: flgVerbose,
AuthToken: getToken(),
}
uri := "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/cacd0ab4-224c-4276-814f-e80a7fea1b3a/Screen_Shot_2020-03-19_at_6.11.37_PM.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAT73L2G45GQ6I6PXS%2F20200320%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20200320T011635Z&X-Amz-Expires=86400&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEPb%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJIMEYCIQCARBficIVNgZU6KsQpgVmlsWMvm64cvznOFSIQrViUEAIhAMojl3CRPCOhLsxR5Q6%2F%2BV28mLpwL4TJjgVBzrLPXUqfKr0DCN%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMjc0NTY3MTQ5MzcwIgwZyKv1lfjAdtO4I9kqkQNvn90XhdlUgA9UpNvIDDGCf%2FcFtyBSBiDtPgU92QmQjJmrCIfslN7g3UnWak2sfCbWQgScGcHafjZv4OG0IuixJGAZPaaMvlOOOy9G3q5JZz4%2BinwtMLf%2BzJBbUp9DDyhdm6rTWOdLxyTtWgfx3LdyBmhn%2FqvBXO6xLjyz4p58cry%2FSUrdTPe47y%2BUbFgbhFxp2zGYj63gHGRDASDzODaibYmxaprj2hSLHuiVfKL1Y582%2F6Gc8AIGNj3IybXG%2Ftn6db0Qh8mTzClIoyEW9VE0b%2BEX2kXE0lFn51ivcPGK3KoJlbcHVeJoQwfmPieq%2BnLkX97ur5VjYx%2F9eiROoIHpsRykLAuC85ZFmthZTDoR6pnSMiVKtWBGQWCOhUm27Jbr4AcPlC%2BYN23GvZgLRIzs9Xw4afsg8vgxkncAfraVqK9h3SSzW2XlXN7DMNaRaowko552oX%2BgcJEaFRO9zK5vsrCp6q1tkgiSqnafeb9MVkUttXNGd94VGWZgyh3FQL%2B6BqMUfIBppFnTGrXHhMXJaTDkys%2FzBTrqAR17y7hpLP5bM9hVoJQolj3N5PmytUXV5dQmtrriIYUWzKRPi68V2b9HMr3H4R%2BkiEdPELfMcWLUVA3mOZkXI2bfm2pTkan%2BfaDSzMmgWMqUcu0C12DG3iE5AEoOKyHZXjQuvgVjKk3RCntFzwntNn0nljM43FxGFiZ1iy0NnK%2Bf21N1tLy43BpO96ABc%2FYtVQ1DNI2o9lPxo8dfO8yWaxC97f%2BfYL4LHtSzwufnN6CJZiPQ9OmGNIxkOBWO6z5eKRudWs2bxvHkapQZ08lFRAKbuosslWu549iM5hrGqaPdD0hTbDEV4rK7CQ%3D%3D&X-Amz-Signature=6c6b08db4167214f255a31df07e27de3387d10a5a1e8b09c8f27cb789a880d67&X-Amz-SignedHeaders=host&response-content-disposition=filename%20%3D%22Screen_Shot_2020-03-19_at_6.11.37_PM.png%22"
rsp, err := client.DownloadFile(uri, "8511412cbfde432ba226648e9bdfbec2")
uri := "https://s3-us-west-2.amazonaws.com/secure.notion-static.com/60550647-d8af-4321-b268-cbb1bab09210/SumatraPDF-dll_iITXbPm55F.png"
rsp, err := client.DownloadFile(uri, "5cc81055-1b81-4f31-9df3-390152d272cf", "table")
if err != nil {
fmt.Printf("c.DownloadFile() failed with '%s'\n", err)
return
Expand Down Expand Up @@ -52,7 +52,7 @@ func testDownloadImage() {
fmt.Printf("block.Source: %s\n", block.Source)
exp := "https://i.imgur.com/NT9NcB6.png"
assert(block.Source == exp, "expected %s, got %s", exp, block.Source)
rsp, err := client.DownloadFile(block.Source, block.ID)
rsp, err := client.DownloadFile(block.Source, block.ID, block.ParentTable)
assert(err == nil, "client.DownloadFile(%s) failed with %s", err, block.Source)
fmt.Printf("Downloaded image %s of size %d\n", block.Source, len(rsp.Data))
ct := rsp.Header.Get("Content-Type")
Expand All @@ -68,7 +68,7 @@ func testDownloadImage() {
fmt.Printf("block.Source: %s\n", block.Source)
exp := "https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e5661303-82e1-43e4-be8e-662d1598cd53/untitled"
assert(block.Source == exp, "expected '%s', got '%s'", exp, block.Source)
rsp, err := client.DownloadFile(block.Source, block.ID)
rsp, err := client.DownloadFile(block.Source, block.ID, block.ParentTable)
assert(err == nil, "client.DownloadFile(%s) failed with %s", err, block.Source)
fmt.Printf("Downloaded image %s of size %d\n", block.Source, len(rsp.Data))
ct := rsp.Header.Get("Content-Type")
Expand Down
2 changes: 1 addition & 1 deletion export_page.go
Expand Up @@ -123,7 +123,7 @@ func (c *Client) ExportPages(id string, exportType string, recursive bool) ([]by
return nil, err
}

dlRsp, err := c.DownloadFile(exportURL, id)
dlRsp, err := c.DownloadFile(exportURL, id, "table")
if err != nil {
return nil, err
}
Expand Down
126 changes: 18 additions & 108 deletions get_signed_file_urls.go
Expand Up @@ -10,67 +10,10 @@ import (
)

const (
signedURLPrefix = "https://www.notion.so/signed/"
s3URLPrefix = "https://s3-us-west-2.amazonaws.com/secure.notion-static.com/"
//s3URLPrefixEncoded = "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/"
notionImageProxy = "https://www.notion.so/image/"
s3FileURLPrefix = "https://s3-us-west-2.amazonaws.com/secure.notion-static.com/"
)

/*
{"urls": [
{
"url" : "https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e5661303-82e1-43e4-be8e-662d1598cd53/untitled",
"permissionRecord": {
"table":"block",
"id":"845fd39c-f048-4d41-a0f8-a83851d17afd"
}
}
]}
*/

type getSignedURLPermissionRecord struct {
Table string `json:"table"`
ID string `json:"id"`
}

type getSignedFileURL struct {
URL string `json:"url"`
Permission getSignedURLPermissionRecord `json:"permissionRecord"`
}

type getSignedFileUrlsRequest struct {
Urls []getSignedFileURL `json:"urls"`
}

// GetSignedFileUrlsResponse is a response of GetSignedFileUrls()
type GetSignedFileUrlsResponse struct {
SignedUrls []string `json:"signedUrls"`
RawJSON map[string]interface{} `json:"-"`
}

// GetSignedFileUrls executes a raw API call /api/v3/getSignedFileUrls
// For files (e.g. images) stored in Notion we need to get a temporary
// download url (which will be valid for only a short period of time)
func (c *Client) GetSignedFileUrls(urls []string, blockIDs []string) (*GetSignedFileUrlsResponse, error) {
req := &getSignedFileUrlsRequest{}
for i, url := range urls {
perm := getSignedURLPermissionRecord{
Table: "block",
ID: blockIDs[i],
}
fu := getSignedFileURL{URL: url, Permission: perm}
req.Urls = append(req.Urls, fu)
}

apiURL := "/api/v3/getSignedFileUrls"
var rsp GetSignedFileUrlsResponse
var err error
rsp.RawJSON, err = doNotionAPI(c, apiURL, req, &rsp)
if err != nil {
return nil, err
}
return &rsp, nil
}

// DownloadFileResponse is a result of DownloadFile()
type DownloadFileResponse struct {
URL string
Expand All @@ -81,51 +24,18 @@ type DownloadFileResponse struct {

// sometimes image url in "source" is not accessible but can
// be accessed when proxied via notion server as
// www.notion.so/image/${source}
// www.notion.so/image/${source}?table=${parentTable}&id=${blockID}
// This also allows resizing via ?width=${n} arguments
//
// from: /images/page-cover/met_vincent_van_gogh_cradle.jpg
// =>
// https://www.notion.so/image/https%3A%2F%2Fwww.notion.so%2Fimages%2Fpage-cover%2Fmet_vincent_van_gogh_cradle.jpg?width=3290
func maybeProxyImageURL(uri string) string {
if strings.HasPrefix(uri, s3URLPrefix) {
return signedURLPrefix + url.PathEscape(uri)
}

// don't proxy external images
if !strings.Contains(uri, "notion.so") {
return uri
}

if strings.Contains(uri, "//www.notion.so/image/") {
return uri
}

// if the url has https://, it's already in s3.
// If not, it's only a relative URL (like those for built-in
// cover pages)
if !strings.HasPrefix(uri, "https://") {
uri = "https://www.notion.so" + uri
}
return "https://www.notion.so/image/" + url.PathEscape(uri)
}

func (c *Client) maybeSignImageURL(uri string, blockID string) string {
if !strings.HasPrefix(uri, s3URLPrefix) {
return maybeProxyImageURL(uri)
}
/* notionapi-py does:
if url.startswith(S3_URL_PREFIX):
url = SIGNED_URL_PREFIX + quote_plus(url)
if client:
url = client.session.head(url).headers.get("Location")
*/
rsp, err := c.GetSignedFileUrls([]string{uri}, []string{blockID})
if err != nil {
func maybeProxyImageURL(uri string, blockID string, parentTable string) string {
if !strings.Contains(uri, s3FileURLPrefix) {
return uri
}
return rsp.SignedUrls[0]
uri = notionImageProxy + url.PathEscape(uri) + "?table=" + parentTable + "&id=" + blockID
return uri
}

func (c *Client) downloadFile(uri string) (*DownloadFileResponse, error) {
Expand Down Expand Up @@ -160,17 +70,17 @@ func (c *Client) downloadFile(uri string) (*DownloadFileResponse, error) {
return rsp, nil
}

// DownloadFile downloads a file stored in Notion
func (c *Client) DownloadFile(uri string, blockID string) (*DownloadFileResponse, error) {
// DownloadFile downloads a file stored in Notion referenced
// by a block with a given id and of a given block with a given
// parent table (data present in Block)
func (c *Client) DownloadFile(uri string, blockID string, parentTable string) (*DownloadFileResponse, error) {
//fmt.Printf("DownloadFile: '%s'\n", uri)
// try proxing through www.notion.so/image/
if strings.Contains(uri, "s3.us-west-2.amazonaws.com") {
uri2 := "https://www.notion.so/image/" + url.PathEscape(uri)
res, err := c.downloadFile(uri2)
if err == nil {
return res, nil
}
// first try downloading proxied url
uri2 := maybeProxyImageURL(uri, blockID, parentTable)
res, err := c.downloadFile(uri2)
if err != nil && uri2 != uri {
// otherwise just try your luck with original URL
res, err = c.downloadFile(uri)
}
uri2 := c.maybeSignImageURL(uri, blockID)
return c.downloadFile(uri2)
return res, err
}
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -4,8 +4,8 @@ require (
github.com/google/uuid v1.1.1
github.com/kjk/caching_http_client v0.0.0-20190810075619-06ff809674f7
github.com/kjk/siser v0.0.0-20190801014033-b3367920d7f2
github.com/kjk/u v0.0.0-20191229080709-d1ac8976d53f // indirect
github.com/stretchr/testify v1.3.0
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 // indirect
)

go 1.11
43 changes: 0 additions & 43 deletions go.sum
Expand Up @@ -7,65 +7,22 @@ github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1p
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kjk/atomicfile v0.0.0-20190916063300-2d5c7d7d05bf h1:HuwmGC6wEC0CdGC3QUSBnAfQzydOiR4HeTZCySsHpHY=
github.com/kjk/atomicfile v0.0.0-20190916063300-2d5c7d7d05bf/go.mod h1:+YlBbo63AHA3uS6tdRhd42B+I1lV7H7+aqDhwTRl5rs=
github.com/kjk/caching_http_client v0.0.0-20190810075619-06ff809674f7 h1:QpTfahFJ/tetY9TR6GeV3ubuzU5qJnmfTk35cJF8/WQ=
github.com/kjk/caching_http_client v0.0.0-20190810075619-06ff809674f7/go.mod h1:uZMXWOA3unK8KYdy6aBIel64MMqZwsRFRKIvgSadLAU=
github.com/kjk/siser v0.0.0-20190801014033-b3367920d7f2 h1:vrqsThWMeIUgprELZhUEw0wFu/LJANlftGo6US4vIDg=
github.com/kjk/siser v0.0.0-20190801014033-b3367920d7f2/go.mod h1:5VyY+9nF1wpSfWAIM/mIrd0fZCiA/6IK6CSf3PnjfMA=
github.com/kjk/u v0.0.0-20191229080709-d1ac8976d53f h1:HGmmQzrSiO8TNUIYoG6lg/DrVeqsFz2CEJeySHQHcRU=
github.com/kjk/u v0.0.0-20191229080709-d1ac8976d53f/go.mod h1:5DUexog+kFLzpHxAQ7R9Of0N8DdhUjbpWGgnc41TMK4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/minio/minio-go/v6 v6.0.44 h1:CVwVXw+uCOcyMi7GvcOhxE8WgV+Xj8Vkf2jItDf/EGI=
github.com/minio/minio-go/v6 v6.0.44/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU=
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 h1:sKJQZMuxjOAR/Uo2LBfU90onWEf1dF4C+0hPJCc9Mpc=
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 h1:JA8d3MPx/IToSyXZG/RhwYEtfrKO1Fxrqe8KrkiLXKM=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.51.1 h1:GyboHr4UqMiLUybYjd22ZjQIKEJEpgtLXtuGbR21Oho=
gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
4 changes: 2 additions & 2 deletions tohtml/html.go
Expand Up @@ -270,7 +270,7 @@ type Converter struct {

// if true, generates stand-alone HTML with inline CSS
// otherwise it's just the inner part going inside the body
FullHTML bool
FullHTML bool
CustomCSS string

// we need this to properly render ordered and numbered lists
Expand Down Expand Up @@ -1248,7 +1248,7 @@ func getImageStyle(block *notionapi.Block) string {
func (c *Converter) RenderImage(block *notionapi.Block) {
c.Printf(`<figure id="%s" class="image">`, block.ID)
{
uri := getFileOrSourceURL(block)
uri := block.ImageURL
style := getImageStyle(block)
c.Printf(`<a href="%s">`, uri)
c.Printf(`<img %ssrc="%s"/>`, style, uri)
Expand Down
2 changes: 1 addition & 1 deletion upload_file.go
Expand Up @@ -31,7 +31,7 @@ type GetUploadFileUrlResponse struct {
}

func (r *GetUploadFileUrlResponse) Parse() {
r.FileID = strings.Split(r.URL[len(s3URLPrefix):], "/")[0]
r.FileID = strings.Split(r.URL[len(s3FileURLPrefix):], "/")[0]
}

// getUploadFileURL executes a raw API call: POST /api/v3/getUploadFileUrl
Expand Down

0 comments on commit e11d5a3

Please sign in to comment.