I try to make a upload/download services of files for my website, and i'm trying to use the object storage from openstack. The thing is, i have no problem doing it via php and openstack php sdk, but when i'm trying to do it via some javascript, i can't find a good sdk or methods.
I'm not using node, I have a php server, and a javascript client. I would like to uploads or download files directly from the javascript client. I don't want the file to transfer through the php server. I managed to create openstack tokens with the php sdk, maybe i could send those to the javascript so then they can authenticate? It's been one week of searching with no solutions...
Openstack has a S3 plugin that can ease your search for a library/sdk.
Otherwise, you should forge a temporary URL server-side, I'm sure your PHP library has tooling for this. The URL can then be used client-side to PUT the file.
The temporary URL is forged in a way to open temporary write-only access for the upload. There is also the same kind of URL to open read-only access to some elements.
So, either the client requests for a place to upload to the PHP which sends back the URL, or simply have the client upload the file to your PHP that will forge the link and then redirect the request to the URL.
Related
I want to upload a file to an FTP server.
I'm using Angular but after some research I realized that Angular has no way to upload files to FTP. So I tried to follow this code but I didn't have any success because 'new FtpConnection()' is not recognized by javascript.
Is there any other valid code to upload a file to FTP via javascript or do I need to upload the file to FTP via the backend? (I use c# in backend)
JavaScript has no native mechanisms for handling input and output, including FTP communication. It depends on the host environment to provide APIs for that.
Browsers (which I assume you are using given your angular tag) do not provide JS with an API for making FTP uploads, so you cannot.
(The question you reference is about JS running in Adobe Photoshop, not in a web browser).
The closest you could get would be to write a web service which you could send a file to via HTTP and then have it make the FTP upload.
Currently, I have a PHP app running on Heroku using a Postgresql database. I want my users to be able to upload an image to a folder on my dropbox, and store other information (in this case, product information such as price, title, weight, location of the image on dropbox) on my database.
Right now, I'm using a file input inside an HTML form to submit the image by posting the whole form to my server (including the image), and then I use cURL to send the image to dropbox and wait for the response to succeed. On success, I create my database record that has the other information I mentioned earlier.
This works well for small files, but Heroku has a 30 second timeout that I can't change. For large files, the whole file uploads to the server, and then it uploads to dropbox. These two upload operations are time-intensive and takes more time than the timeout allows.
I had the idea of sending the file to dropbox using javascript (jQuery ajax commands specifically) so that it's handled by the client, and then POSTing to my server on success, but I'm worried about how secure that is since I would need to have my own authorization tokens in the source code that the client can view.
Is there any way for PHP to send a file from the client to an external URL without it touching the server? How do I do this securely?
This sounds like a good fit for the Dropbox API /2/files/get_temporary_upload_link endpoint.
You can call that on your server to retrieve the temporary upload link, and then pass that link down to the browser. You can then have some JavaScript code perform the upload directly from the browser using that link.
Since only the /2/files/get_temporary_upload_link endpoint call requires your Dropbox access token (whereas the temporary upload link itself doesn't), you can keep your access token secret on the server only, without exposing it to the client. And since the upload happens directly from the browser to the Dropbox servers, you don't have to pass the file data through your own server, avoiding the timeout issue.
First off, I know this seems illogical when I could just send the download URL to the server. The issue with that is that user's can access these download links and so for those who can I need to be able to download it. I can't really explain why as I am under NDA.
I am trying to download a file from a URL via the client (browser) and stream the data directly to the server where the file is saved so the client essentially acts as a "middleman" and does not require the file to be downloaded to the client's machine.
I have been experimenting with "socket.io-stream" and "socket.io-file" but i am having a few issues with both. "socket.io-stream" allows me to upload a specific file from the client to the server but the uploaded file has a size of 0kb and doesn't have any examples on Github.
"socket.io-file" has examples, which I followed and currently have it setup so I can use an input tag to select a file to upload to the server successfully.
From what I can see the "socket.io-file" upload function takes a file object as the parameter.
So I have two questions really:
Is there a plugin for JS (Browser) & NodeJs (Server) that would allow me to do this?
or
How can I create a File Object from an external url?
I solved this is the end, using a chrome extension to download the file as a blob object, pass the object to the content script and then use socket.io-stream to upload it to the server.
I want to upload user uploaded file (from website <form>) to my FTP server, in which I want to bypass the server and want that file should be sent to FTP server directly. Is it possible using PHP or JavaScript?
In current scenario when I upload file using HTML form and PHP to Apache server, the file is stored in /tmp/ directory and then I can transfer it to FTP location. But this takes double time in uploading as the filed is first uploaded to Apache server and then to the FTP server.
Cloud servers run this way, where Apache server can be by passed and file can be posted directly to cloud server)
I want this so that we can overcome the HTTP part and want to upload large file to FTP server without getting any HTTP upload restrictions.
The HTML form tag does not support the FTP.
You cannot use PHP either as it cannot access local (as of webbrowser) files.
So JavaScript is the only likely solution.
The XMLHttpRequest class theoretically supports FTP:
Despite its name, XMLHttpRequest can be used to retrieve any type of data, not just XML, and it supports protocols other than HTTP (including file and ftp).
But in reality it probably does not.
See the accepted answer to What is the syntax to do a cross-domain XMLHTTPREQUEST to an FTP server?
So actually, there does not seem to be any solution readily available.
If possible, run a web server on the FTP server host and send the files using the web server (HTTP).
Another alternative is to stick with the transferring via your web server, but in a streaming mode. Post your file to the web server. Make the handling script continuously read the incoming data and have them continuously uploaded to the FTP server.
You won't save a bandwidth, but you will save time (as both transfers happen nearly in parallel).
Using the ftp_fput with a handle to the standard input should do (didn't try).
its very difficult to FTP data(BIGfile) to backup server without using HTTP protocol in a web application.
Lets say, S1-( Client Browser ), S2-(code container server), S3-(Files Backup server) and we want to upload 2gb file from s1 using FTP.
use case diagram This can be done by "JavaApplet" . we can embed uploader applet in webapplication. This applet will run inside browser sand box.
go through link sample code for ftp using applet
provided you have to enable java on your browser.sample code
ftp block diagram for side load
I have a static page that does not use any server-side scripting and would like to grab the date a file was last modified (or created) with an ajax request using javascript or jquery. Is this possible?
Nope. In order to access the file on a server, you need some sort of server-side scripting
If you are trying to grab the information for a file hosted with some third-party service and you have access to their API, then you can send them an ajax request. Of course this is assuming their API allows you to request that information on a file.