Open lullis opened 11 years ago
Any update on this? I see the file class, but not how upload the file
Nothing so far. Unfortunately I've been busy with many other projects to give attention to this one.
Is there any example for updating a file/image by using ParsePy?
Has anyone made concessions on this feature of the library?
Is there any update on this? or any pointer or example using ParsePy?
I'll try implementing this this weekend. But of course we'd welcome push requests if anyone else solves it.
@dgrtwo thanks for taking on this. Do you know any update on ACL/Roles support? it is listed as TODO/PLANNED action item in the ReadMe section. If there isn't any plan soon to implement this, do you have any recommendation on what is a good way/approach to do this?
Facing this problem right now.
Anyone have hints on how to implement a solution?
I'm thinking reading from request.FILES and saving to Parse.File
I had written code to upload images/mp3 files with md5 checksum support already after realizing ParsePy does not support file uploading. This works fine for me and is being used extensively by me. All I need to do is modify it a bit and integrate it into ParsePy and create a pull request. Can I someone give me some pointers on how to do this? I see ParsePy already supports File datatype but not for modifying it I think. Is this right?
That's very interesting. If you're willing to share the code in a comment, I might be able to help you get it integrated. I got stuck on this a while back (and should have put more time into it).
Spent some time diving into the code for the File class . I think we already have this functionality in place. The file class here already seems to be doing what I am doing. Can't we upload a file using the File class this way
file = File ('/home/user/test.mp3')
file.save()
I am a little lost here. looks like @dankrause already added File Support.
Oh! I merged that pull request last month but somehow forgot (I guess I'd been associating it with a different problem). This one's on me, sorry I wasted your time.
I need to write documentation and tests for the feature before I close this issue. As discussed in the pull request the class could probably use improvement.
Hum, I have an issue using this #15.
2 different ways:
#use local file
fileParse = File(name="grab.jpg")
fileParse.save()
return this (with many different image files): UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128).
The error is raised in connexion.py (line 99-100): data = data.encode('utf-8')
# use distant image file
fileParse = File(name="image.jpg", url=url_file)
# fileParse.save() # save no needed
see attached. One click on the object in the table shows an xml file in the browser:
```<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>.....</RequestId>
<HostId>.....</HostId>
</Error>```
Do I miss something ?
Yeah, it looks like the file upload code was never tested with binary files. I'll see if I can put something together tonight that properly encodes binary files before uploading.
Any improvements?
For me, I just remove the encode("ut8-8") in connexion.py (line 99-100): data = data.encode('utf-8') to data = data and then it works
Hi,
I also get the error UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
but in my code data = data.encode('utf-8')
is on line 111 in connection.py
Any suggestions would be cool.
Actually, you need to modify 2 lines in connection.py. 1) line 111. from data = data.encode('utf-8') to data = data; 2) line 120. from request = Request(url, data, headers) to request = Request(url.encode('utf-8'), data, headers)
hope it works for you.
@treeguard you were right. Making those two changes did the trick. Thanks!
Doesn't this need a PR for a clean integration into the library ?
I suggest passing a keyword argument into the class method POST through File save method when dealing with binaries. Something like no_encoding = True; And then a simple check will bypass encoding only with binaries.
@konoufo Parse is going to be closed in 6 months. Do we really need this PR now?
Other Parse Server hostings might support this.
Date: Fri, 8 Jul 2016 23:20:15 -0700 From: notifications@github.com To: ParsePy@noreply.github.com CC: konoufo@hotmail.fr; mention@noreply.github.com Subject: Re: [milesrichardson/ParsePy] Upload File/Images. (#15)
@konoufo Parse is going to be closed in 6 months. Do we really need this PR now?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
@konoufo Which ones, for example?
Maybe Sashido or back4app; did not read all the docs but well it's a possibility.
Date: Sat, 9 Jul 2016 01:06:58 -0700 From: notifications@github.com To: ParsePy@noreply.github.com CC: konoufo@hotmail.fr; mention@noreply.github.com Subject: Re: [milesrichardson/ParsePy] Upload File/Images. (#15)
@konoufo Which ones, for example?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
connection = http.client.HTTPSConnection('api.parse.com', 443)
connection.connect()
connection.request('POST', '/1/files/image.png', open(myImage.png, 'rb').read(), {
"X-Parse-Application-Id": "",
"X-Parse-REST-API-Key": "",
"Content-Type": "image/png"
})
result = json.loads(connection.getresponse().read().decode('utf-8'))
restaurant = Restaurant(name = x.name, image={'__type': 'File', 'name':result['name'], 'url':result['url']})
restaurant.save()
Right now there is no way to upload files/images to Parse through our library. We need to implement these functions on the File/Image data types.