How to upload a file to GCS using javascript? - javascript

I am trying to upload a file to GCS using javascript.
I found this answer which shows how to upload and see the progress of that file.
I also followed the official documentation
All of the above worked for me, but now i want to allow anyone who visits my website to upload to the bucket i have. I don't want to authenticate using the button that the documentation shows. I just want anyone to be able to visit the website, upload and see the progress of the upload file.
The main issue i have is that i want users to be able to see the PROGRESS of the upload file. Maybe there is another way.
Thanks

To make it work you need to:
Configure Cross Origin Resource Sharing (CORS)
Generate signed url for file upload. You can check example in python how to do it or example server side app in node.js
Use resumable multiple chunks upload to show upload progress.

Related

"Box Embed" type preview for Dropbox in PHP/java-script based website

i have integrated Dropbox with php based application using their API. Files are uploaded and then shared URL is stored in PHP application.
Show any file preview: I did some R&D and find out that using shared URL in iframe can display preview. But iframe cant be responsive and also this is proper way to preview any uploaded file in application?
If you want to get the preview data for a file and then control how it's displayed, you can use /2/files/get_preview.
Dropbox doesn't offer a way to do this, but we'll consider it a feature request.
EDIT:
Dropbox has released a preview of a new pre-built component for embedding files and folders! You can find more information about the Dropbox Embedder in our blog post here:
https://dropbox.tech/developers/new-file-and-folder-embedder-launched-in-preview
There's also a chance to win a $200 Amazon gift card if you fill out a survey about the new Dropbox Embedder. Check out the blog post above for more information.

Upload File Using Url to Box content-api

I did some research and i couldn't find any information regarding this,
I know that box content-api call to upload needs to be form-data
is there way to upload file via giving a url of the file?
like for example i want to save this file,
https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png
without downloading it on to the computer (client side). and than uploading it with api.
It is not currently possible to upload a file with the Box API using a URL to a file.
When calling the Upload File endpoint for the Box API, you have to specify the file's location on your local machine or server.

How to upload file to the page path?

I search it every where but not found right answer, I'm trying to upload file using jQuery plugin, But I don't know to where file save when I upload file using this plugin.
My need is when file upload it save automatically to the page path.
Plugin Url:
http://hayageek.com/docs/jquery-upload-file.php
Demo Here
To upload a file to a website you need a server listening to request on the end. Jquery can be used to simplify getting the file to the server but once there the server has to accept it and copy it to the hard drive. Think about it like this, it would be a real problem if anyone could post anything to your server and have it be copied to your server. Hope this helps, or at least points you in the right direction.

jQueryFileUpload upload a file given its URL

I'd like to use jQueryFileUpload to upload a file that is not on my computer but rather is at an external website so all I have is its URL, e.g., https://dl.dropboxusercontent.com/s/wkfr8d04dhgbd86/onarborLogo64.png.
I'm at a total loss on how to do this but I think it involves adding the file data programmatically rather than using the traditional <label for='myComputerFiles'>-based selection of files.
If this is correct, what next FileReader()?
Any thoughts would be appreciated.
You should do this on the server - it requires user intervention to download it locally, and that just seems hacky and unfriendly.
Reason? You would have to first download the file (which is an indeterminate process), and then upload it to the server. If you pass the URL to the server then it can perform the whole process in 1 action - a download (which is effectively the same as you uploading it). Also, the ability to read local files, which is what FileReader is for, does not mean you should download files to just upload them again. That's bad logic and your users will not appreciate it.
Also, Dropbox Chooser is not meant to be a way to download files. It's meant to be a replacement for downloading file, or uploading them to other servers... ...without having to worry about the complexities of implementing a file browser, authentication, or managing uploads and storage.
Since you're using S3, if there is an API call on S3 that allows you to specify a URL then that would be the most obvious thing to use. If you can't do that then you either need to download the file for the user (onto your server) and then upload the file to S3, or you're back to the original idea of downloading at the client and uploading from there. Either way, the introduction of S3 obviously adds another layer of complication, but I'd initially look at getting a URL from the client and getting that file on my server so I could do anything I wanted after that.
This previous question may be of some help in this area...
How to upload files directly to Amazon S3 from a remote server?

How to use valum's file uploader in conjunction with Amazon S3 storage?

I have a file upload form where the file gets uploaded to an S3 bucket at Amazon. I am using https://bitbucket.org/david/django-storages/wiki/Home for that purpose.
Basic file uploading works fine and does it's job but now I would like to integrate an Ajax file uploader into the form and I settled with "valum's file-uploader", using the following fork: https://github.com/alexkuhl/file-uploader
I also stumbled across the following blogpost detailing how to save a file with that backend: http://kuhlit.blogspot.com/2011/04/ajax-file-uploads-and-csrf-in-django-13.html
My experience with ajax file uploads is limited (I used SWFUpload once but I'd prefer a flashless solution this time around) and from the looks of the blogpost the file gets saved on the servers file system. What I would like to do is integrate the upload script with the s3 backend provided by django-storages. Ideally, no byte from the file gets saved on the webserver but passed through to s3.
Any pointers to built in Django functions, blog posts, general ideas are welcome. Moreover, if anyone has a suggestion for another upload script where I can achieve my goal more easily, feel free to suggest it.
I made it work by configuring the uploader to use the hidden iframe method. Now it works together nicely with django's backend. However, I am missing some convience features like drag&drop now.

Categories