From e11d5a303e967569b9389827ba3c973353cf4906 Mon Sep 17 00:00:00 2001 From: Krzysztof Kowalczyk Date: Sun, 20 Jun 2021 17:40:41 -0700 Subject: [PATCH] hopefully fix downloading images from image blocks --- block.go | 9 +- caching_downloader/caching_downloader.go | 7 +- do/main.go | 4 + do/tests_adhoc.go | 8 +- export_page.go | 2 +- get_signed_file_urls.go | 126 ++++------------------- go.mod | 2 +- go.sum | 43 -------- tohtml/html.go | 4 +- upload_file.go | 2 +- 10 files changed, 40 insertions(+), 167 deletions(-) diff --git a/block.go b/block.go index 3368edd..7fcc6b3 100644 --- a/block.go +++ b/block.go @@ -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 @@ -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 @@ -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 diff --git a/caching_downloader/caching_downloader.go b/caching_downloader/caching_downloader.go index 8bbc39d..5aef57e 100644 --- a/caching_downloader/caching_downloader.go +++ b/caching_downloader/caching_downloader.go @@ -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 @@ -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 diff --git a/do/main.go b/do/main.go index 2a27262..5ce0238 100644 --- a/do/main.go +++ b/do/main.go @@ -192,6 +192,10 @@ func main() { must(os.MkdirAll(cacheDir, 0755)) + if false { + flgPreviewHTML = "da0b358c21ab4ac6b5c0f7154b2ecadc" + } + if false { testDownloadFile() return diff --git a/do/tests_adhoc.go b/do/tests_adhoc.go index 0b06bc0..e1e7b36 100644 --- a/do/tests_adhoc.go +++ b/do/tests_adhoc.go @@ -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 @@ -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") @@ -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") diff --git a/export_page.go b/export_page.go index cd7ac24..ce19c7a 100644 --- a/export_page.go +++ b/export_page.go @@ -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 } diff --git a/get_signed_file_urls.go b/get_signed_file_urls.go index cf51c8e..e9a3b9f 100644 --- a/get_signed_file_urls.go +++ b/get_signed_file_urls.go @@ -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 @@ -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) { @@ -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 } diff --git a/go.mod b/go.mod index d2ffbb9..9af738a 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 57bd2e4..0b3496e 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/tohtml/html.go b/tohtml/html.go index d154322..f43a216 100644 --- a/tohtml/html.go +++ b/tohtml/html.go @@ -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 @@ -1248,7 +1248,7 @@ func getImageStyle(block *notionapi.Block) string { func (c *Converter) RenderImage(block *notionapi.Block) { c.Printf(`
`, block.ID) { - uri := getFileOrSourceURL(block) + uri := block.ImageURL style := getImageStyle(block) c.Printf(``, uri) c.Printf(``, style, uri) diff --git a/upload_file.go b/upload_file.go index 2793ccd..2c2cf15 100644 --- a/upload_file.go +++ b/upload_file.go @@ -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