facebook-python-business-sdk icon indicating copy to clipboard operation
facebook-python-business-sdk copied to clipboard

filename param for AdImage

Open tomako opened this issue 11 years ago • 7 comments

filename is definitely a string containing path and name. But sometimes it would be useful passing just a file-like object because we have the file only in memory. We could modify the methods to process also file object but the parameter's name is still filename. So it could be misleading. Any suggestion?

tomako avatar May 07 '15 16:05 tomako

We can modify it to have a filename or file parameter and check to see one or the other exists. It then allows someone working on top of the SDK to be explicit about what they want to pass in.

ebzlo avatar May 07 '15 16:05 ebzlo

Yes, that's a possible way though I would avoid using file as parameter name. My only concern is the def remote_create_from_zip(cls, filename, parent_id, api=None) because I have to change that to def remote_create_from_zip(cls, filename=None, parent_id=None, api=None, fileobject=None) to keep the current order of parameters.

tomako avatar May 07 '15 17:05 tomako

That's a good point @tomako

Open to your thoughts on this suggestion:

The second method signature is definitely not ideal, especially for someone who wants to take advantage of the fileobject parameter without specifying argument names. If we modify ordering we'll create a breaking change for anybody who's not specifying argument names in method calls.

How about we have filename check for object type: string vs object and deal with it appropriately (I realize that's super confusing, but bear with me).

Add an additional parameter to remote_create_from_zip named file, which simply acts as an alias to filename. def remote_create_from_zip(cls, file=None, parent_id=None, api=None, filename=None):

  • The method now needs to validate that filename or file came through.

We can post breaking changes in the README.md that filename is deprecated and file will take its place (and that the method is now polymorphic).

In the next major patch, I will remove filename.

ebzlo avatar May 07 '15 17:05 ebzlo

Alright, it sounds good. So should add a new field to AdImage and deal with it on the same way as do with filename (string vs. object checking). And the zip method also would get a new field as you defined. Must validate that filename or the new field is passed (and also the parent_id). The only thing we should agree the name of this new parameter. Since file is a type name I wouldn't use it although it would be perfect. What about image_file and zip_file (for zip method)?

tomako avatar May 07 '15 21:05 tomako

Hah, for all my caveats I just spotted in the standard lib that ZipFile has a file parameter and the description is suprisingly "file can be either a path to a file (a string) or a file-like object". I don't fight :)

tomako avatar May 08 '15 13:05 tomako

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

ghost avatar Aug 04 '15 18:08 ghost

Closing this out because AdImage is one of the autogenerated files. We will try and incroporate this change in our codegen framework

rituparnamukherjee avatar Apr 13 '16 17:04 rituparnamukherjee