EzDevInfo.com

file-transfer interview questions

Top file-transfer frequently asked interview questions

rsync error: failed to set times on "foo.txt": Operation not permitted

I'm getting a confusing error from rsync and the initial things I'm finding from web searches (as well as all the usual chmod'ing) are not solving it:

rsync: failed to set times on "/foo/bar": Operation not permitted (1)
rsync error: some files could not be transferred (code 23) 
  at /SourceCache/rsync/rsync-35.2/rsync/main.c(992) [sender=2.6.9]

It seems to be working despite that error, but it would be nice to get rid of that.


Source: (StackOverflow)

how to achieve transfer file between client and server using java socket [duplicate]

This question already has an answer here:

I have implement the simple TCP server and TCP client classes which can send the message from client to server and the message will be converted to upper case on the server side, but how can I achieve transfer files from server to client and upload files from client to server. the following codes are what I have got.

TCPClient.java

        import java.io.*;
        import java.net.*;
        import java.util.Scanner;

 class TCPClient {

public static void main(String args[]) throws Exception {
        int filesize=6022386;
        int bytesRead;
        int current = 0;
    String ipAdd="";
    int portNum=0;
    boolean goes=false;
    if(goes==false){
    System.out.println("please input the ip address of the file server");
    Scanner scan=new Scanner(System.in);
    ipAdd=scan.nextLine();
    System.out.println("please input the port number of the file server");
    Scanner scan1=new Scanner(System.in);
    portNum=scan1.nextInt();
    goes=true;
    }
    System.out.println("input done");
    int timeCount=1;
    while(goes==true){
    //System.out.println("connection establishing");

    String sentence="";
    String modifiedSentence;

    BufferedReader inFromUser = new BufferedReader(new InputStreamReader(
            System.in));

    Socket clientSocket = new Socket(ipAdd, portNum);
    //System.out.println("connecting");
    //System.out.println(timeCount);
    if(timeCount==1){
    sentence="set";
    //System.out.println(sentence);


    }
    if(timeCount!=1)
        sentence = inFromUser.readLine();
            if(sentence.equals("close"))
                clientSocket.close();
            if(sentence.equals("download"))
            {
                byte [] mybytearray  = new byte [filesize];
                InputStream is = clientSocket.getInputStream();
                FileOutputStream fos = new FileOutputStream("C:\\users\\cguo\\kk.lsp");
                BufferedOutputStream bos = new BufferedOutputStream(fos);
                bytesRead = is.read(mybytearray,0,mybytearray.length);
                current = bytesRead;
                do {
   bytesRead =
      is.read(mybytearray, current, (mybytearray.length-current));
   if(bytesRead >= 0) current += bytesRead;
} while(bytesRead > -1);

bos.write(mybytearray, 0 , current);
bos.flush();
long end = System.currentTimeMillis();
//System.out.println(end-start);
bos.close();
clientSocket.close();
            }
           // if(sentence.equals("send"))
               // clientSocket.
    timeCount--;
    //System.out.println("connecting1");
    DataOutputStream outToServer = new DataOutputStream(clientSocket
            .getOutputStream());

    BufferedReader inFromServer = new BufferedReader(new InputStreamReader(
            clientSocket.getInputStream()));


    //System.out.println("connecting2");
    //System.out.println(sentence);
    outToServer.writeBytes(sentence + "\n");

    modifiedSentence = inFromServer.readLine();

    System.out.println("FROM SERVER:" + modifiedSentence);

    clientSocket.close();

}
}

}


TCPServer.java

          import java.io.*;
       import java.net.*;

     class TCPServer {
public static void main(String args[]) throws Exception {

    Socket s = null;

    int firsttime=1;


    while (true) {
        String clientSentence;
    String capitalizedSentence="";

        ServerSocket welcomeSocket = new ServerSocket(3248);
        Socket connectionSocket = welcomeSocket.accept();

             //Socket sock = welcomeSocket.accept();


        BufferedReader inFromClient = new BufferedReader(
                new InputStreamReader(connectionSocket.getInputStream()));

        DataOutputStream outToClient = new DataOutputStream(
                connectionSocket.getOutputStream());

        clientSentence = inFromClient.readLine();
        //System.out.println(clientSentence);
                    if(clientSentence.equals("download"))
                    {
                         File myFile = new File ("C:\\Users\\cguo\\11.lsp");
  byte [] mybytearray  = new byte [(int)myFile.length()];
  FileInputStream fis = new FileInputStream(myFile);
  BufferedInputStream bis = new BufferedInputStream(fis);
  bis.read(mybytearray,0,mybytearray.length);
  OutputStream os = connectionSocket.getOutputStream();
  System.out.println("Sending...");
  os.write(mybytearray,0,mybytearray.length);
  os.flush();
  connectionSocket.close();
                    }
        if(clientSentence.equals("set"))
            {outToClient.writeBytes("connection is ");
            System.out.println("running here");
            //welcomeSocket.close();
             //outToClient.writeBytes(capitalizedSentence);
            }



        capitalizedSentence = clientSentence.toUpperCase() + "\n";


    //if(!clientSentence.equals("quit"))
           outToClient.writeBytes(capitalizedSentence+"enter the message or command: ");


        System.out.println("passed");
        //outToClient.writeBytes("enter the message or command: ");
        welcomeSocket.close();
    System.out.println("connection terminated");
    }
}

}

So, the TCPServer.java will be executed first, and then execute the TCPClient.java, and I try to use the if clause in the TCPServer.java to test what is user's input,now I really want to implement how to transfer files from both side(download and upload).Thanks.


Source: (StackOverflow)

Advertisements

Transfer files to/from session I'm logged in with PuTTY

I'm logged into a remote host using PuTTY.

What is the command to transfer files from my local machine to the machine I'm logged into on PuTTY?


Source: (StackOverflow)

How to transfer files to Amazon EC2 instance from my Windows 7 computer?

I want to be able to transfer a number of files (html, php, jpg, etc...) to my Amazon EC2 instance that I'm hosting my web server on. What is the easiest or most effective way to do this?


Source: (StackOverflow)

IBM MQ for file transfer [closed]

We are facing a choice to use IBM MQ over SFTP for file transfer. I've heard advantages of such approach, but I've never see anyone actually using it for a large files.

So main question: how well IMB MQ can handle transfer of large files (up to 100 MB)? Is it stable? It's from mainframe to UNIX server, if it does matter.

Thanks a lot.


Source: (StackOverflow)

Access a Remote Directory from C#

I am trying to access a remote network share from a C# program in asp.net. What I need is something like

function download(dirname)
{
    directory = (This is the part I don't know how to do)

    for dir in directory:
        download(dir);

    for file in directory:
        copyfile(file);

}

My problem is that the directory requires a username and password for access and I don't know how to provide them. Thanks for any help you can offer.


Source: (StackOverflow)

File transfer between android and iPhone via bluetooth?

I was thinking of developing an iPhone and android application so that they can share data between each other via bluetooth. Is it possible? If yes how?

Thanks for your help


Source: (StackOverflow)

What is the maximum file size I can transfer using HTTP? And using FTP?

Added: I am conducting a study for a new system we're going to develop in my work. It consists in authenticating users, displaying what files they want to download and downloading them. Also, if the files are not readily available, the user can't download them, but the server obtains a copy of the requested file and notifies the user by mail when he can get the file. We expect files to be tipically from 2 to 50 gigabytes in size, for now.

I just want to check if it's possible to write a Web application to solve the problem or if we need to make a client-server solution.


Source: (StackOverflow)

Upload to PHP server from c sharp client application

Currently i have a c sharp application (Client app). and a web application written php. I want to transfer some files whenever a particular action is performed at client side. Here is the client code to upload the file to php server..

private void button1_Click(object sender, EventArgs e)
{
    System.Net.WebClient Client = new System.Net.WebClient();

    Client.Headers.Add("Content-Type", "binary/octet-stream");

    byte[] result = Client.UploadFile("http://localhost/project1/upload.php", "POST",
                                      @"C:\test\a.jpg");

    string s = System.Text.Encoding.UTF8.GetString(result, 0, result.Length); 
}

Here is the upload.php file to move the file..

$uploads_dir = './files/'; //Directory to save the file that comes from client application.
foreach ($_FILES["pictures"]["error"] as $key => $error) {
  if ($error == UPLOAD_ERR_OK) {
     $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
     $name = $_FILES["pictures"]["name"][$key];
     move_uploaded_file($tmp_name, "$uploads_dir/$name");
 }

I'm not getting any errors from above code. but it does not seem to be working. Why is it? Am i missing something?


Source: (StackOverflow)

Reliable and fast way to transfer large files over the internet

I'm working with a setup involving many clients PCs and some server machines. I need to organize a reliable and fast method of file transfer between these PCs, that will be initiated by C# apps running on both. Any client may want to send/receive data from any server. The options are:

  • FTP - Use FtpWebRequest or SOSFTP to upload files onto an FTP server. The server checks for new files on its filesystem and does the required steps.

  • SCP - Secure file transfer. Usage same as FTP but increased security between machines. Probably slower than FTP.

  • DropBox / Box.Net - Use an online cloud storage solution with a library such as SharpBox. May be free / paid. May be less secure considering the said party has your files.

  • UDP - Use a library such as EME or GoAnywhere to transfer data from PC to PC directly via UDP. Probably faster but probably more unreliable since it uses custom technology.

What do you recommend?


Source: (StackOverflow)

Managed File Transfer - any viable open source options out there?

I'm currently looking at options with the aim of replacing our current bespoked and unsupported MFT soultion. As well as the usual Ipswitch, Axway and Sterling type solutions I was wondering whether anyone knew of any serious open source offerings currently available?


Source: (StackOverflow)

How do you store a file locally using Apache Cordova 3.4.0

I am having a problem storing a file locally on an iOS (or android) device using apache cordova's "file" plugin. The problem I believe is setting the path properly.

this is the error message I get from Xcode Could not create path to save downloaded file: The operation couldn\U2019t be completed. (Cocoa error 512.)

Here is the code where I am attempting to save the file locally:

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">


document.addEventListener("deviceready", onDeviceReady, false);

var root;


function onDeviceReady(){
    // Note: The file system has been prefixed as of Google Chrome 12:
    window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onInitFs, errorHandler);
}

function onInitFs(fs) {


    var fileURL = "cdvfile://localhost/persistant/file.png";

    var fileTransfer = new FileTransfer();
    var uri = encodeURI("http://upload.wikimedia.org/wikipedia/commons/6/64/Gnu_meditate_levitate.png");

    fileTransfer.download(
            uri,
            fileURL,
            function(entry) {
                console.log("download complete: " + entry.fullPath);
            },
            function(error) {
                console.log("download error source " + error.source);
                console.log("download error target " + error.target);
                console.log("upload error code" + error.code);
            },
            false,
            {
                headers: {
                    "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
                }
            }
    );
}


function errorHandler(e) {
  var msg = '';

  switch (e.code) {
    case FileError.QUOTA_EXCEEDED_ERR:
      msg = 'QUOTA_EXCEEDED_ERR';
      break;
    case FileError.NOT_FOUND_ERR:
      msg = 'NOT_FOUND_ERR';
      break;
    case FileError.SECURITY_ERR:
      msg = 'SECURITY_ERR';
      break;
    case FileError.INVALID_MODIFICATION_ERR:
      msg = 'INVALID_MODIFICATION_ERR';
      break;
    case FileError.INVALID_STATE_ERR:
      msg = 'INVALID_STATE_ERR';
      break;
    default:
      msg = 'Unknown Error';
      break;
  };

  alert('Error: ' + msg);
}

</script>

Source: (StackOverflow)

Save file to public directory using Cordova FileTransfer

I need to download files on my mobile device and make them accessible for other apps (using Android and iOS).

I managed to download a file to the SD card (cordova.file.externalDataDirectory), but this only exists on Android and even then I cannot rely on every device having an SD card.

When I download to the device storage (cordova.file.dataDirectory), the file is private to my app and therefore not accessible for other apps. The file can be opened in the InAppBrowser, but I would prefer to use the respective default app.

Is there a way to get a path to a directory publicly available on all devices?

The paths returned by the solution suggested in http://stackoverflow.com/a/21375812/3432305 are both private on Android...

EDIT:

I think I should describe my use case so it's clearer what I'm trying to achieve: I want to open files from my in app chat using the respective default app (pdf viewer, image viewer etc.). Because the Cordova File Opener plugin only accepts files from the local file system, I need to save them first. But they don't necessarily need to be accessible from outside my app afterwards...


Source: (StackOverflow)

File Transfer using Java JSch - SFTP

here is my code, which retrieves content of the file, on the remote server and display as output.

package sshexample;

import com.jcraft.jsch.*;
import java.io.*;

public class SSHexample 
{
public static void main(String[] args) 
{
    String user = "user";
    String password = "password";
    String host = "192.168.100.103";
    int port=22;

    String remoteFile="sample.txt";

    try
    {
        JSch jsch = new JSch();
        Session session = jsch.getSession(user, host, port);
        session.setPassword(password);
        session.setConfig("StrictHostKeyChecking", "no");
        System.out.println("Establishing Connection...");
        session.connect();
        System.out.println("Connection established.");
        System.out.println("Crating SFTP Channel.");
        ChannelSftp sftpChannel = (ChannelSftp) session.openChannel("sftp");
        sftpChannel.connect();
        System.out.println("SFTP Channel created.");
        InputStream out= null;
    out= sftpChannel.get(remoteFile);
        BufferedReader br = new BufferedReader(new InputStreamReader(out));
        String line;
        while ((line = br.readLine()) != null) 
    {
            System.out.println(line);
        }
    br.close();
        sftpChannel.disconnect();
        session.disconnect();
    }
    catch(JSchException | SftpException | IOException e)
{
    System.out.println(e);
}
}
}

now how to implement this program that the file is copied in the localhost and how to copy a file from localhost to the server.

here how to make work the transfer of files for any format of files.


Source: (StackOverflow)

Which Protocol is best for File Transfer [closed]

What is the best protocol I can use to transfer a big file, which should be fast and reliable? It must support low bandwidth systems since I need a file transmission across India. The file size may be 100 to 500MB.


Source: (StackOverflow)