Hi!

I think you've found the wrong mailing list for this post. This mailing
list is for the development of Django itself, not for support using Django.
This means the discussions of bugs and features in Django itself, rather
than in your code using it. People on this list are unlikely to answer your
support query with their limited time and energy. Read more on the mailing
lists at https://www.djangoproject.com/community/

For support, please use the django-users mailing list, or IRC #django on
Freenode, or a site like Stack Overflow. There are people out there willing
to help on those channels, but they might not respond if you don't ask your
question well. Stack Overflow's question guide can help you frame it well:
https://stackoverflow.com/help/how-to-ask .

Also if you haven't read it, please take a look at Django's Code of
Conduct: https://www.djangoproject.com/conduct/ . These are our "ground
rules" for working well as a community, and will help you get the most out
of Django and our fantastic community.

*As for your question*: Sreevardhan's example code reads the whole uploaded
file which isn't ideal. Instead look at UploadedFile.chunks() .

Thanks for your understanding,

Adam

On Fri, 6 Sep 2019 at 13:01, Sreevardhan Reddy <sreevardhanre...@gmail.com>
wrote:

> here is the code
>
> if request.method == 'POST':
>      hash = request.FILES['uploaded_file'].read()[:-500]
>      #check if a hash exists in the database
>
>
> On Friday, September 6, 2019 at 5:14:35 PM UTC+5:30, Milind Yadav wrote:
>>
>> Hi,
>>
>> I am trying to receive the first 500 bytes of a file coming from
>> client-side before it gets completely downloaded onto the server.
>>
>> I need to compute the hash value of the first 500 bytes and compare with
>> hashes in database. If no match is found then resume the download i.e.
>> remaining bytes are sent and the file gets saved onto the server.
>>
>>
>> *PSEUDO-CODE:*
>>
>> from django.incoming.data import packets
>>
>> first_500 = []
>>
>> for packet in packets*:*
>>
>>     if first_500.size+packet.body.size <= 500 bytes*:*
>>         first_500.append(packet.body)
>>
>>     else*:*
>>         temp = packet.body.slice_body(500 bytes-first_500.size)
>>         first_500.append(temp)
>>         break
>>
>>
>> This will save a lot of time and space in case a duplicate is encountered.
>>
>> Regards
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/b0fdc2ad-d331-45b0-a8f3-9fb1cf823bd9%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/b0fdc2ad-d331-45b0-a8f3-9fb1cf823bd9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM0UB%3Ds5SqebrQcs0hVq2tiTTHXXoQDySUGmDab1DmRb%3DA%40mail.gmail.com.

Reply via email to