Skip to content

Issues with current uploading file by URL implementation  #236

@Syfaro

Description

@Syfaro

There are a number of issues with the current implementation of uploading files by URL. Primarily, using the documented method of a url.URL results in a panic. This panic is caused by the io.MultiReader created by the multipartstreamer package having a nil field. The nil field exists because UploadFile is called even for a url.URL type which does not set a file, resulting in the default nil value.

Another issue is that uploading by URL requires Parsing a URL. Given that there is no actual requirement for it to be Parsed and it is immediately converted back into a string, it would make sense to avoid this requirement altogether. A new type, similar to FileBytes or FileReader, could be introduced containing a string representation of the URL which avoids the performance hit of having to Parse it.

I plan to introduce a new type named FileURL containing a URL string field. Request would then be modified to include a check for if the file field of the Fileable was of the type FileURL, and if it was, would modify the Params to contain the Fileable field name with the contents of the URL field of the FileURL. It would then call the MakeRequest method. Given that passing a url.URL is currently broken, this should not be a breaking change.

Please let me know if I have overlooked anything or you have suggestions to improve this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions