ncw / swift

Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)
MIT License
310 stars 107 forks source link

Expose CloseWithError on ObjectCreateFile #155

Closed damz closed 4 years ago

damz commented 4 years ago

Expose .CloseWithError on ObjectCreateFile to allow uploads to be aborted.

Ideally, we would add this to DynamicLargeObjectCreate and StaticLargeObjectCreate but because of the support for seeking it looks like it gets complicated very quickly. I am happy to help do that, but I would need guidance on the best way to do it, and I would rather do that in a separate PR.

ncw commented 4 years ago

Expose .CloseWithError on ObjectCreateFile to allow uploads to be aborted.

That looks great... I'll merge that now.

Ideally, we would add this to DynamicLargeObjectCreate and StaticLargeObjectCreate but because of the support for seeking it looks like it gets complicated very quickly. I am happy to help do that, but I would need guidance on the best way to do it, and I would rather do that in a separate PR.

Its been a while since I looked at that code!

It occurs to me that a context.Context is probably the proper tool for the job. However the swift lib was written a long time before context was a thing so it would require a whole new set of interfaces and be a lot of work to retro-fit.

Any other ideas?

damz commented 4 years ago

The Google Storage implementation asks you to provide a context when creating the writer. It is a pain the neck to use, because you can only control the overall operation, not each writes. It also exposes the CloseWithError method which I replicated here.

ncw commented 4 years ago

The Google Storage implementation asks you to provide a context when creating the writer. It is a pain the neck to use, because you can only control the overall operation, not each writes. It also exposes the CloseWithError method which I replicated here.

I see.

I'd be open to either or both if you wanted to send a PR...