NebulousLabs / go-skynet

An SDK for integrating Skynet into Golang applications
MIT License
16 stars 8 forks source link

Filename query parameter when only 1 file #26

Closed xloem closed 3 years ago

xloem commented 4 years ago

I was copying some of the upload interface into the python sdk, and I noticed that when only one file is being uploaded, the filename url parameter is passed but not given any content. It's around this area of code. https://github.com/NebulousLabs/go-skynet/blob/c2e7fd3bc47fc9e5564aa5ca2a17512e09c08f52/upload.go#L79

If you look at that if block, you'll see only fieldname is set, unlike the else condition, but right below there is: https://github.com/NebulousLabs/go-skynet/blob/c2e7fd3bc47fc9e5564aa5ca2a17512e09c08f52/upload.go#L90

filename is used but was never set. I'm not familiar with go, but I'm guessing this variable likely contains an empty string here, possibly whatever was last in local memory where it's allocated.

When copying to python, I figured it was safer and clearer to give this parameter the actual filename, but I don't know for sure if that is the correct behavior. Does the server ignore the filename parameter when there is one named multipart file? Does it fill it in automatically when it's empty? Or is this a bug?

I've seen in my metadata queries that many records do have the filename listed twice: once on the whole record, and again within the content alongside the size. So I figured the query parameter might set the outer name, but I don't really know. Is this documented concisely somewhere?

EDIT: I've significantly reworded the above.

mrcnski commented 3 years ago

Thanks for the submission. The filename parameter is redundant in the case of a single file.

Is this documented concisely somewhere?

Nope. https://gitlab.com/NebulousLabs/Sia/-/issues/4408

mrcnski commented 3 years ago

MR: https://gitlab.com/NebulousLabs/Sia/-/merge_requests/4884