I made ajax image upload. How can I get image dimensions before file is uploaded? Or how can I stop uploading.
I wrote custom upload handler and have strange situation. If I'am trying to stop uploading file in "new_file" procedure by raising StopUpload(True) error - it works, but if I'am trying in receive_data_chunk procedure - it does not (actually django stops processing file, but server is still receiving data from client).
I use apache+mod_python.
Tnx.
Rather than rolling your own, I would use something like django-jquery-file-upload
Related
I have Laravel backend with Intervention package to handle images.
All images are stored in S3 bucket and are accessed through CDN - Cloudfront distribution.
When user requests image from my app I use something like this line to fetch image and return it to user.
return Image::make("https://*********.cloudfront.net/S3_image_path_and_filename.jpg")->response()->header('Cache-Control', 'max_age=3600');
This code worked without any troubles for more than a year without any changes but recently I started to see that some images on client side are empty and there are errors saying
Intervention\Image\Exception\NotReadableException Unable to init from given url
I looked up for issues with missing images but they exist in S3 bucket and are accessible through Cloudfront. I even see them on client side after clearing cache or waiting for some time - so this issue is flacky, can't reproduce it. I even don't see any error associated with images in Cloudfront distribution.
My questions are
what could be the reasons behind this issue?
how I can debug it?
maybe I need to handle the exception above but I am not sure what should be returned to user in that case?
I have ha form, the form have more than one file uploading field like upload logo, upload background. While I am uploading the files using Codeigniter I can display uploading errors using using $this->upload->display_errors() call. But in my form I have two files to upload. I want to make error message more specific. Like:
=====Logo error====Codeigniter uploading error message for logo
=====Background error====Codeigniter uploading error message for background
As both of the files are uploading in the same form the display_errors() method return all the file uploaded error messages as combined. I tried to keep the errors at variable when logo upload error occurred. Then add just only the background error messages with that variable. But when adding the background error calling the method display_errors(), it return not only the background error but also the logo uploading error. It may be possible by clearing the display_errors() methods return value after the logo errors. But is it possible with codeigniter? Or how to get my desired output. Thanks.
I implemented the websocket file upload implementation as described on:
http://code.tutsplus.com/tutorials/how-to-create-a-resumable-video-uploade-in-node-js--net-25445
It worked great on my Ubuntu VM. But when I uploaded the code to a CentOS 6 server, images didn't work when they got uploaded. I then tried uploading a large text file, and it was fine. I then tried a ZIP, and it still didn't work. The file on the server and the file being uploaded have exactly the same file size so it appears to work fine. I can only assume some sort of character encoding issue? But basically I am really stuck. Anyone got any ideas?
I'm tempted to try using Ajax to get it working if I haven't made any progress in the next day or 2.
I found solution.I had to apply new chain rule for iptables,and allow server to listen on custom port for web sockets..After that,everything works great. I had to make it permanent.
I'm currently trying to upload image using ASP web API and save it in my Azure server using this tutorial
Then I took the request stream using Request.Content.ReadAsStreamAsync().Result and send it to Azure using blob.UploadFromStream(stream);
The file got uploaded and when I fetch the URL it returns something like
http://testing.cloudapp.net:10000/devstoreaccount1/saveFiles/File_2_2.zip
I tried the link but it just returns a blank page.
Any idea why I can't download my uploaded file back?
It turns out I should just use blob.UploadFile(fullLocalPathFileName) instead of blob.UploadFromStream(stream). You can get the full local path of your file from the MultipartFormDataStreamProvider and just send it easily to the blob.
Do you know best way to upload too many files to Azure Blob container?
I am currently do something to upload multiple files to Azure blob storage. The number of files may be huge, like 30,000 or more(each file could be sized of 10KB~1MB). Firstly, I have a list of files locations, then I would use Parallel.Foreach to upload the files. code snippet like this:
`List locations=...
Parallel.Foreach(locations, location=>
{
...
UploadFromStream(...);
...
});`
The codes run to inconsistence results.
Sometimes it runs well, I can see all files uploaded to the Azure blob container.
Sometimes, I will got exceptions like this:
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature., Inner Exception: The remote server returned an error: (403) Forbidden
Sometimes, I got a timeout exception.
I have worked against the issue for several days, unfortunatly, I havn't got a perfect solution yet. So I want to know how do you do when you handling similar scenario, how do you do when upload too many files to Azure blob storage?
Finally, I have not found what's wrong with my code.
However, I have found solution for this issue. I expire Parallel.Foreach, just use common foreach. Then I use BeginuploadFromStream method instead of UploadFromStream, it actually upload files asynchronously.
So far, it runs prefectly, more stable, without any exception happens.