public FileNewCopyResponse FileNewCopy( string filePath, long fileID, bool isFileShared, string message, string[] emailsToNotify) { string destinationUrl = string.Format(FILE_NEW_COPY_URI_TEMPLATE, _token, fileID); MultipartWebRequest request = new MultipartWebRequest(destinationUrl, Proxy); FileNewCopyResponse response; try { string serverResponse = request.SubmitFiles(new[] { filePath }, isFileShared, message, emailsToNotify); response = MessageParser.Instance.ParseFileNewCopyResponseMessage(serverResponse); } catch (Exception ex) { response = new FileNewCopyResponse { Error = ex, Status = FileNewCopyStatus.Failed }; } return response; }
public void FileNewCopy( string filePath, long fileID, bool isFileShared, string message, string[] emailsToNotify, OperationFinished<FileNewCopyResponse> fileNewCopyCompleted, object userState) { ThrowIfParameterIsNull(fileNewCopyCompleted, "fileNewCopyCompleted"); string destinationUrl = string.Format(FILE_NEW_COPY_URI_TEMPLATE, _token, fileID); MultipartWebRequest request = new MultipartWebRequest(destinationUrl, Proxy); object[] state = new[] { fileNewCopyCompleted, userState, fileID }; request.SubmitFiles(new[] { filePath }, isFileShared, message, emailsToNotify, FileNewCopyFinished, state); }
/// <summary> /// Asynchronously adds files to the specified folder /// </summary> /// <param name="files">Paths to files to upload</param> /// <param name="destinationFolderID">ID of the destination folder</param> /// <param name="isFilesShared">Indicates if uploaded files should be marked as shared</param> /// <param name="message">Text of the message to send in a notification email to all addresses in the <paramref name="emailsToNotify"/> list</param> /// <param name="emailsToNotify">List of email addresses to notify about newly uploaded files</param> /// <param name="filesUploadCompleted">Callback method which will be invoked after operation completes</param> /// <param name="userState">A user-defined object containing state information. /// This object is passed to the <paramref name="filesUploadCompleted"/> delegate as a part of response when the operation is completed</param> /// <exception cref="ArgumentException">Thrown if <paramref name="filesUploadCompleted"/> is <c>null</c></exception> public void AddFiles( string[] files, long destinationFolderID, bool isFilesShared, string message, string[] emailsToNotify, OperationFinished<UploadFileResponse> filesUploadCompleted, object userState) { ThrowIfParameterIsNull(filesUploadCompleted, "filesUploadCompleted"); MultipartWebRequest request = new MultipartWebRequest(string.Format(UPLOAD_FILE_URI_TEMPLATE, _token, destinationFolderID), Proxy); object[] state = new[] {filesUploadCompleted, userState, destinationFolderID}; request.SubmitFiles(files, isFilesShared, message, emailsToNotify, UploadFilesFinished, state); }
/// <summary> /// Adds files to the specified folder /// </summary> /// <param name="files">Paths to files to upload</param> /// <param name="destinationFolderID">ID of the destination folder</param> /// <param name="isFilesShared">Indicates if uploaded files should be marked as shared</param> /// <param name="message">Text of the message to send in a notification email to all addresses in the <paramref name="emailsToNotify"/> list</param> /// <param name="emailsToNotify">List of email addresses to notify about newly uploaded files</param> /// <returns>Operation status</returns> public UploadFileResponse AddFiles( string[] files, long destinationFolderID, bool isFilesShared, string message, string[] emailsToNotify) { MultipartWebRequest request = new MultipartWebRequest(string.Format(UPLOAD_FILE_URI_TEMPLATE, _token, destinationFolderID), Proxy); UploadFileResponse response; try { string serverResponse = request.SubmitFiles(files, isFilesShared, message, emailsToNotify); response = MessageParser.Instance.ParseUploadResponseMessage(serverResponse); } catch (Exception ex) { response = new UploadFileResponse { Error = ex, Status = UploadFileStatus.Failed, UploadedFileStatus = new Dictionary<File, UploadFileError>() }; } response.FolderID = destinationFolderID; return response; }
/// <summary> /// Asynchronously overwrites existing file with the new one /// </summary> /// <param name="filePath">Path to new file</param> /// <param name="fileID">ID of the old file to overwrite</param> /// <param name="isFileShared">Indicates if uploaded file should be marked as shared</param> /// <param name="message">Text of the message to send in a notification email to all addresses in the <paramref name="emailsToNotify"/> list</param> /// <param name="emailsToNotify">List of email addresses to notify about newly uploaded files</param> /// <param name="overwriteFileCompleted">Callback method which will be invoked after file-overwrite operation completes</param> /// <param name="userState">A user-defined object containing state information. /// This object is passed to the <paramref name="overwriteFileCompleted"/> delegate as a part of response when the operation is completed</param> /// <exception cref="ArgumentException">Thrown if <paramref name="overwriteFileCompleted"/> is <c>null</c></exception> public void OverwriteFile( string filePath, long fileID, bool isFileShared, string message, string[] emailsToNotify, OperationFinished<OverwriteFileResponse> overwriteFileCompleted, object userState) { ThrowIfParameterIsNull(overwriteFileCompleted, "overwriteFileCompleted"); MultipartWebRequest request = new MultipartWebRequest(string.Format(OVERWRITE_FILE_URI_TEMPLATE, _token, fileID), Proxy); object[] state = new[] { overwriteFileCompleted, userState, fileID }; request.SubmitFiles(new[] { filePath }, isFileShared, message, emailsToNotify, OverwriteFileFinished, state); }
/// <summary> /// Overwrites existing file with the new one /// </summary> /// <param name="filePath">Path to new file</param> /// <param name="fileID">ID of the old file to overwrite</param> /// <param name="isFileShared">Indicates if uploaded file should be marked as shared</param> /// <param name="message">Text of the message to send in a notification email to all addresses in the <paramref name="emailsToNotify"/> list</param> /// <param name="emailsToNotify">List of email addresses to notify about newly uploaded files</param> /// <returns>Operation status</returns> public OverwriteFileResponse OverwriteFile( string filePath, long fileID, bool isFileShared, string message, string[] emailsToNotify) { MultipartWebRequest request = new MultipartWebRequest(string.Format(OVERWRITE_FILE_URI_TEMPLATE, _token, fileID), Proxy); OverwriteFileResponse response; try { string serverResponse = request.SubmitFiles(new[] { filePath }, isFileShared, message, emailsToNotify); response = MessageParser.Instance.ParseOverwriteFileResponseMessage(serverResponse); } catch (Exception ex) { response = new OverwriteFileResponse { Error = ex, Status = OverwriteFileStatus.Failed, UploadedFileStatus = new Dictionary<File, UploadFileError>() }; } return response; }