Skip to content

setFiles #21

Open
Open
@vgavrilovikj

Description

@vgavrilovikj

I can see in the Entities\Properties - Files is listed as property, however, setFiles() function is not present in the Page.php..

Is this something that can be added? Thank you :) @mechelon

Activity

johguentner

johguentner commented on Jun 27, 2021

@johguentner
Member

Hi @vgavrilovikj,
thank you so much for the question!
Currently the notion api unfortunately does not allow you to directely download or upload files.
For file properties, only the pure file-names (no path or url) can be retrieved at the moment.

You can see this in the dev-description for the notion-api:
https://developers.notion.com/reference/page#files-property-values

To be sure, I also searched a bit, and also found a small stackoverflow-thread, which describes the current state:
https://stackoverflow.com/questions/67551832/notion-api-how-to-get-the-url-of-uploaded-files

Since the property can be retrieved in some way the property class Files::class exist, but cannot be set within the page with'setFiles'.

🎯 To avoid confusion, we'll plan to use a 'modifiable'-trade within property classes, to clarify, if a page property can be modified within page update and creation. This will be the case in version 0.5.0 or latest in 0.6.0 of laravel-notion-api.

As soon as the notion api gets updated in some way, we'll make sure to include the feature asap.
This includes setting/uploading files within pages
🔥😊

added
enhancementNew feature or request
blocked by dependencyFuture feature, which has to wait until the notion-api supports this feature
on Jun 27, 2021
vgavrilovikj

vgavrilovikj commented on Jun 28, 2021

@vgavrilovikj
Author

Hey, @johguentner thank you so much for getting back on such short notice!

Cool, I wanted to use it so I can insert images (from URL) into Notion, but for the time being, I made it work by changing the Notion property to URL so I can insert the URL and when I need the image, I will just change the property type to File & media so I can view the image..

But totally as soon as Notion updates their API would be good to use the setFiles

johguentner

johguentner commented on Jun 28, 2021

@johguentner
Member

For sure @vgavrilovikj!

Yeah, that seems like the best practice for now!
That's right... url-strings are also possible for images. I'll try in the next few days, if setting the files-property with url-strings works.

Of course! We'll make sure to attach the linked pull-request to this issue and write a short notice, as soon as it's out ✨.

johguentner

johguentner commented on Jul 18, 2021

@johguentner
Member

Hi @vgavrilovikj,
just wanted to let you know, that it's currently not possible with the notion-api to set even urls within files-properties.

I implemented the following:

# retreive page with property "Files" as files-property
$page = \Notion::pages()->find($pageId);
$page->set("Files", Files::value([$imgurl]));
$page = \Notion::pages()->update($page);

# the patched/posted data the laravel-notion-api is generating is the following:
array:1 [
  "properties" => array:1 [
    "Files" => array:1 [
      "files" => array:1 [
        0 => array:1 [
          "name" => "<<the_inserted_url>>"
        ]
      ]
    ]
  ]
]

The notion-api accepts the patch-request, however the files-property "Files" is not updated at all.

We'll have an eye on the changelog of the notion-api (https://developers.notion.com/changelog)
and will support setting files, as soon as the notion-api allows it ✨.

removed
blocked by dependencyFuture feature, which has to wait until the notion-api supports this feature
on Sep 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @johguentner@vgavrilovikj

        Issue actions

          setFiles · Issue #21 · 5am-code/laravel-notion-api