io.UnsupportedOperation: seek #59

Closed
opened 2022-02-18 12:58:26 +01:00 by in0rdr · 3 comments

Hi,

I really like this service a lot.

During a deployment I received the following error message when uploading remote files via the "url" field:

io.UnsupportedOperation: seek

I can kind of reproduce the issue, since the file stream there is not "seekable":

import requests

def urlfile(**kwargs):
        return type('',(),kwargs)()

r = requests.get('https://i.imgflip.com/1igc7m.jpg', stream=True, verify=False, headers={ "Accept-Encoding" : "identity" })

f = urlfile(stream=r.raw, content_type=r.headers["content-type"], filename="")

data = f.stream.read()
f.stream.seek(0)
>>> f.stream.seekable()
False

>>> f.stream.seek(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
io.UnsupportedOperation: seek

The issue is mainly appearing when trying to save remote urls with the "url" parameter like so:

curl -F'url=https://i.imgflip.com/1igc7m.jpg' https://0x0.example.com

The issue does not appear on the reference instance https://0x0.st, so it's probably just me :) Would appreciate any hint or feedback on how to make it work with the saving of remote urls.

Many thanks.

Hi, I really like this service a lot. During a deployment I received the following error message when uploading remote files via the "url" field: ``` io.UnsupportedOperation: seek ``` I can kind of reproduce the issue, since the file stream there is not "seekable": ``` import requests def urlfile(**kwargs): return type('',(),kwargs)() r = requests.get('https://i.imgflip.com/1igc7m.jpg', stream=True, verify=False, headers={ "Accept-Encoding" : "identity" }) f = urlfile(stream=r.raw, content_type=r.headers["content-type"], filename="") data = f.stream.read() f.stream.seek(0) ``` ``` >>> f.stream.seekable() False >>> f.stream.seek(0) Traceback (most recent call last): File "<stdin>", line 1, in <module> io.UnsupportedOperation: seek ``` The issue is mainly appearing when trying to save remote urls with the "url" parameter like so: ``` curl -F'url=https://i.imgflip.com/1igc7m.jpg' https://0x0.example.com ``` The issue does not appear on the reference instance https://0x0.st, so it's probably just me :) Would appreciate any hint or feedback on how to make it work with the saving of remote urls. Many thanks.
Owner

Sorry about the late response. Could you tell me more about your server configuration? Like the app server running your instance, and what’s facing the client (e.g. nginx). Include config file snippets.

Sorry about the late response. Could you tell me more about your server configuration? Like the app server running your instance, and what’s facing the client (e.g. nginx). Include config file snippets.
mia added the
question
label 2022-08-01 17:48:30 +02:00
Author

Thanks for getting back to me.

I was using Nomad with Nginx at that time. All the code and configuration is stored here:

It worked really well for me. Was running the deployment on Raspberry Pie. That might be relevant.

Thanks and have a good day

Thanks for getting back to me. I was using Nomad with Nginx at that time. All the code and configuration is stored here: - https://codeberg.org/in0rdr/nomad-0x0 - https://codeberg.org/in0rdr/docker-0x0 It worked really well for me. Was running the deployment on Raspberry Pie. That might be relevant. Thanks and have a good day
Owner

Hm. There are definitely some issues with 0x0’s code in the affected function. No idea why seeking that stream is even working for me! Something must be implicitly buffering the response, but only in some environments (gunicorn apparently is not one of those).

Anyway, this should be an easy thing to fix.

Hm. There are definitely some issues with 0x0’s code in the affected function. No idea why seeking that stream is even working for me! Something must be implicitly buffering the response, but only in some environments (gunicorn apparently is not one of those). Anyway, this should be an easy thing to fix.
mia added
bug
and removed
question
labels 2022-08-01 20:11:44 +02:00
mia referenced this issue from a commit 2022-08-11 05:48:57 +02:00
mia closed this issue 2022-08-11 05:48:57 +02:00
mia referenced this issue from a commit 2022-08-11 05:49:52 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mia/0x0#59
No description provided.