Skip to content

Commit

Permalink
fix: fix upload result URL parser
Browse files Browse the repository at this point in the history
fix #31, fix #32, fix #33
  • Loading branch information
vzhd1701 committed Oct 17, 2023
1 parent abede1e commit 5734913
Show file tree
Hide file tree
Showing 38 changed files with 5,625 additions and 4,639 deletions.
11 changes: 8 additions & 3 deletions csv2notion/notion_row_upload_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ def _upload_file(block: Block, file_path: Path) -> str:


def get_file_id(image_url: str) -> Optional[str]:
match = re.search("secure.notion-static.com/([^/]+)", image_url)
if match:
return match[1]
# aws_host/space_id/file_id/filename
aws_re = r"^https://(.*?\.amazonaws\.com)/([a-f0-9\-]+)/([a-f0-9\-]+)/(.*?)$"

aws_match = re.search(aws_re, image_url)

if aws_match:
return aws_match.group(3)

return None


Expand Down
2 changes: 1 addition & 1 deletion tests/cassettes/test_column_types_file_upload.uuid4.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["eb15d198-f382-419b-a27f-e253b6681a29", "4aa49805-6a39-4cbf-9b78-562ee8141403", "30ade129-78f9-4a86-9a43-4a5580dfd736", "236757b6-3922-4f8a-a1e3-8353f25cad51"]
["f0cd4b7f-8524-41f7-9029-f9bdfc2da7cf", "186d0a30-243c-47d5-b4ca-788da05bc6da", "f05f59f2-f2ff-4cd8-a48f-3ad573c20352", "d3873275-7d31-4e96-ae1b-251dc8ec4784"]
432 changes: 234 additions & 198 deletions tests/cassettes/test_column_types_file_upload.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/cassettes/test_default_icon_file.uuid4.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["ce098bd0-34e8-4554-878d-7203df8b8c64", "849cfd43-d1f9-4837-b2ce-897289a0eea8", "ab8bfa74-af94-4529-910d-4adc85a97518", "eb421061-38dd-47d8-a6ec-531318e99368"]
["cec82367-003e-4ec6-8a96-95ac7423a9f2", "3ae4fbf4-c20a-460b-a9b7-9d849aa36f13", "de44cd36-b9c7-46c8-9b24-653bc6c69c13", "650c4191-152d-4ac5-95cb-38584f79843c"]
469 changes: 255 additions & 214 deletions tests/cassettes/test_default_icon_file.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/cassettes/test_icon_column_ok.uuid4.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["cf439ac6-629f-4fa5-aae9-c744b56e5660", "bcbc9b4c-b27f-4e71-ac1a-17de8330aec2", "50c24504-3ba1-4947-8a64-bad3d4e52fd2", "4ea87358-265f-4118-84a1-6845c86915ec"]
["165fae50-f9cb-4c04-903b-5e3da4d85ad2", "9da5f76b-1892-480f-9624-0ad16d81b6bb", "e34a8203-18a3-49e3-8d8e-f944d968bd62", "88c7d1f3-4c01-49bf-b3e4-a8bd8370ba88"]
498 changes: 272 additions & 226 deletions tests/cassettes/test_icon_column_ok.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/cassettes/test_image_caption_column_ok.uuid4.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["01c2efe4-b61e-4db8-a774-8e27ac438228", "384cbfd7-0e29-4023-ab30-08884fb3edb4", "8a6de7cf-c5f6-4a4e-8017-2b1bf0029245", "49456146-712e-4295-82e0-de0d4b09393b", "8dfa46be-902c-4075-a751-101fc8c16638"]
["85b26110-a73a-4ce9-9203-a3414d05183c", "8ddf25fa-18dc-4cb1-a46e-4252f9af30c7", "67251589-6c8b-4542-9009-9a0c601a0c64", "d0295f84-db46-4b52-b599-aabe6c6f52d7", "6db07e75-6317-4f44-9df9-59fb2acd61b0"]
542 changes: 311 additions & 231 deletions tests/cassettes/test_image_caption_column_ok.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/cassettes/test_image_column_cover_mode_ok.uuid4.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["2378f1fd-8448-40fa-8389-8de46fe8bd32", "3bfcf28a-4415-44e0-ac53-2ca30259271a", "642aebfe-54d0-4f50-ba3e-14ea545b56c2", "cbb4cb3e-ab0f-4518-837d-68b1cae25de7"]
["cd2a8450-c3d7-431e-9e7c-350fa7f27bd6", "592f1131-7823-4bca-a4a1-718edc58626b", "ee837a06-b9c4-409c-bf4d-31f659b48341", "06d99257-9143-49a6-b789-d7fbbc73b1e9"]
498 changes: 272 additions & 226 deletions tests/cassettes/test_image_column_cover_mode_ok.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/cassettes/test_image_column_ok.uuid4.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["5346ceeb-a483-491f-a81b-5941ca60f894", "71484d3c-3404-4433-8ef9-5a8c05a0489d", "c6b58d57-7776-4ef9-92f7-8133b36fa444", "802720dd-9b06-4839-ade4-4d94621c007a", "49a352b9-c747-4db3-a41b-c9885797ca75"]
["4e2c8948-de20-4487-8032-6da749a49dc8", "6919454f-308d-46fe-b52f-98e4a221a253", "a90ec39e-484b-4e06-8aad-fb8c7a630838", "b2fecabf-0a92-48c4-9ca2-32ad4aab9489", "3e800be4-0c6a-4a20-afb0-5f02d42dd6ae"]
602 changes: 330 additions & 272 deletions tests/cassettes/test_image_column_ok.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
["c05c9059-de0b-4f27-84e7-43ed7e3b3a48", "6048273d-8acd-4d75-80c5-b19f0cd742f0", "0c89dfc1-7a85-4cdb-b5a3-1c03c867b29b", "6ac5bfea-1fd0-4912-a3ee-a1dc56871e65"]
["e1b069ac-cae7-4615-810f-d5c01b8718eb", "212021f8-9f57-4f42-a58f-575ac03258d9", "41c38ce2-6032-461c-8fca-a9dba8a62af3", "90f9e686-f58c-4e78-9e73-4fbf7f3a0920"]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
["4f2dc0d3-2381-4ac5-bf7f-f9bdaee8b233", "85bf2650-88ee-48b8-8dea-4d5bd710fa1e", "ca2c5674-8687-4f9f-b6f6-e2226834378d", "b0b11ae9-f7be-4f63-ae02-056ed144d492"]
["ccb5b879-aa59-417d-bcdc-9597e3b44915", "eed670f0-08e8-45c3-a17d-2ceca42ed769", "70ce0f1a-09cd-413e-ab55-798ea46e9083", "16b6ccf0-25e9-4039-aa92-c4dd348e671f"]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
["f33720fa-977e-46e6-8c2c-2c11ee5d2bd0", "3aa8a05e-734c-473b-8bc5-e4967bdddc9f", "143a73a5-b113-4b09-9845-51dd54c404a7", "c957c33e-617b-4bce-b1df-f8b9c1b6e658"]
["f8e75f0c-32cf-4a93-8787-fc52f362697a", "54c8ced8-2a7c-4b56-8869-1ff9afbb043f", "7d9eef98-d173-445a-a7a7-391e172fa948", "2e5c9bdf-356d-46ab-a2e8-6e1d7bf47871"]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
["d8142fc9-cccd-46f3-88f5-1ec8a5aa3d88", "c0d87b33-496b-4175-81c1-4d9f51ab6b39", "4ea4a58e-aee7-4079-9d69-13263bc1ee58", "393e3853-52c0-48fe-8c35-a201e2c64b67"]
["985efcea-4019-4fa4-897f-ecaf18ec2da2", "1f07bd4c-8d5d-428d-ad2f-e5822b2dbf7d", "b1f479b2-4f64-4232-8190-1d22b1acb154", "124d34ca-0fd7-45a9-aa18-f3b1aeb8cb11"]
622 changes: 315 additions & 307 deletions tests/cassettes/test_merge_column_types_file_with_content_reupload.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
["618ccd87-94fb-4f4b-90ee-50ab5452a9d8", "2fa3066c-d5e6-4c1a-ad0e-65e654589c04", "130e3e3c-2b06-4ec6-85f3-f91646d65adf", "2ffee686-a882-48c3-bec5-167923f0a615"]
["ff9ad1f2-84e3-4b53-9479-08ab8998a8ed", "20514ea8-d2ad-418b-abbd-dc985f7c7143", "c9f47da8-4e1e-46ea-8fc6-e781c9baa20d", "03e99d3e-be44-4afc-a2e0-368970319b19"]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
["73a8adb0-ec3a-4e0e-b0d8-8cb525f78880", "7fa0e3c2-5efd-4212-ba2d-fa9d6503f126", "4699a7bc-c568-4b02-aa7c-4454f86334e2", "06dac81e-54bd-4fd3-9342-3f7c726b241e"]
["80b3d26d-81ee-48f0-b098-450db8d5d873", "0d96f7af-7469-49bd-a01f-34285d3bb401", "546c83ce-5462-4af8-8e1b-8b43ca42fb3c", "b0fdc0fd-3727-4da1-bcc6-7a93666c7089"]
Loading

0 comments on commit 5734913

Please sign in to comment.