Can I use REST to copy files from on library in a HNSC to another library in a different HNSC (or even different Tenants)

Hi
I am building a SharePoint hosted app which uses a REST Call to get file details of a file held in a host web library. Ok if want to copy that file to another a library held in another HNSC. Surely this is possible subject to the app manifest permission
set to   tenant .  
https://msdn.microsoft.com/office/office365/api/files-rest-operations#Folder6
Daniel, WSL

Reken
Yes it is difficult. I coded up 3 requests in a SharePoint hosted app
1) get file properties
 2) readfile  ( binarycontent)
 3) write file (binarycontent) to library in another HNSC
1- 2 works fine but I am struggling with the 3) 
To stop me from despairing ;-(  I thought I would modify my app to simply do a local copy ...
However, this  not as simple as it looks.....
(BTW this may be better discussed in a new post....)
listurldir = "/appsdev/Marketing Lib;
itemurl = "/Marketing Lib/betterlivingwithoutprogramming.pdf";
filename = "betterlivingwithoutprogramming.pdf";
// Get file to Copy This works with a GET and no Header
var urlGetLocalFile = appweburl +
"/_api/SP.AppContextSite(@target)/web/folders/GetByUrl('" + listurldir + "')/Files/getbyurl('" + filename + "')?@target='" + hostweburl + "'";
executor.executeAsync(
url: urlGetLocalFile,
method: "GET",
success: Function.createDelegate(this, function (data, errorCode, errorMessage) {
// binary data available in data.body
deferred.resolve(data, errorCode, errorMessage);
error: Function.createDelegate(this, function (data, errorCode, errorMessage) {
deferred.reject(data, errorCode, errorMessage);
This works and finds my file ...... ok so far so good lets do a local copy with
CopyTo
localtargetfilepath = "/appsdev/Shared Documents/BeterLivingwithoutanyProgrammingever.pdf"var urlWriteLocalFile = appweburl +
    "/_api/SP.AppContextSite(@target)/web/folders/GetByUrl('" + listurldir + "')/Files/getbyurl('" + filename + "')/copyTo(strNewUrl='" + localtargetfilepath + "', bOverWrite=true)?@target='" + hostweburl + "'";
 executor.executeAsync(
            url: urlWriteLocalFile,
            method: "POST",
            success: Function.createDelegate(this, function (data, errorCode, errorMessage) {
                // binary data available in data.body
                deferred.resolve(data, errorCode, errorMessage);
            error: Function.createDelegate(this, function (data, errorCode, errorMessage) {
                deferred.reject(data, errorCode, errorMessage);
Unfortunately, I can't get passed this error  
I have changed the HtpRuntime paramenters as in maxrequestlength and maxurlLength/. 
Tried various header combinations with one or more of the following headers
method: "POST",
headers: {
"Accept": "application/json; odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
binaryStringResponseBody: true,
However, I simply can't get passed the error
Any ideas anyone?
Daniel, WSL
Freelance consultant

Similar Messages

  • How can I use JAVA to copya file from a location to another location?

    Hello all,
    I am planning to design a web page (let say an HTML has a form that post fields to a jsp page) that allow me to select a file and then copy it to another location like what we see in email attachement.
    Is the any related java class that i can use for this matter or ready JavaBean?
    Thanks in advance
    Yahya

    jspSmartUpload
    look for package named com.jspsmart.upload.
    Very easy to use to pull a file from a person's pc up to where the form is posted to. You will need to setup your form to type to be multi-part form. Use an input type of file to generate the file browse button.

  • HT203106 Can I use AirDrop to send files from iPhone 5 to my iPad Air 2?

    Can I use AirDrop to send files from iPhone 5 to my iPad Air 2?

    Yes.
    Use AirDrop to wirelessly share content - Apple Support

  • Can I use iTunes in cloud computing from public library computers or admin. protected computers that don't allow downloading applications or saving user files?

    can I use iTunes in cloud computing from public library computers?
    Can I subscribe to a external database that will let me us apple software from public compute?r--more often than not a PC.

    Are you signed in?
    Image of where this is in iTunes 11: https://discussions.apple.com/message/20585561

  • Using robocopy to copy files from a network share over a WinRS command line session

    Hello,
    Preface: Using server 2008 enterprise.
    I can't seem to get robocopy to function over WinRS and I'm not sure where the problem actually lies.  Running robocopy locally on the computer does work fine, but as soon as I try to run it through a remote command prompt through the WinRS client or directly with the WinRS client I get an access denied message (error 5).
    I've tried using runas while logged into the remote command prompt as well, thinking that it could have been some sort of permissions inheritence issue.
    I've checked the permissions on the remote file share, I've even given 'Everyone', 'Anonymous Logon' and the computer's active directory account full control over the folder and the file I'm trying to copy, but still get the access denied error.
    I've tried using /COPY:DT since I read that usually resolved error 5 issues.
    None of these things have worked.
    I'm kind of out of ideas, I've read some blogs of people who have written powershell scripts which use winrm/robocopy so I figure I'm missing something stupid.  Or maybe I've stumbled upon a bug?
    C:\>robocopy \\192.168.100.1\share c:\test example.exe
       ROBOCOPY     ::     Robust File Copy for Windows
      Started : Mon Feb 09 17:35:32 2009
    2009/02/09 17:35:32 ERROR 5 (0x00000005) Getting File System Type of Source \\192.168.100.1\share\
    Access is denied.
       Source - \\192.168.100.1\share\
         Dest : c:\test\
        Files : example.exe
      Options : /COPY:DAT /R:1000000 /W:30
    2009/02/09 17:35:32 ERROR 5 (0x00000005) Accessing Source Directory \\192.168.100.1\share\
    Access is denied.

    Yep, I verified permissions on them all :(
    To maybe complicate the issue, I looked at the environment variables for myself while logged in locally to the computer and through WinRS and they look to be the same.   
    EDIT: Out of pure frustration I wrote a quick console application which impersonates the currently logged in user and copies a file from the network share I'm trying to access to the local computer.  The application properly impersonates the user - but does not copy the files while it's run through WinRM.  When you run the application as a locally logged in user it works just fine.
    WinRM must be behaving goofy :(
     This is the output of the following application:
    C:\Windows\System32>test.exe 
    Name: domain\loggedinuser 
    IsAuthenticated: True 
    User: {GUID} 
    AuthenticationType: Kerberos 
    Destination directory doesn't exist, creating new directory.. 
    Undoing impersonation.. 
    No exceptions, no nothing :(
    Imports System.IO 
    Imports System.IO.File 
    Module Module1 
       Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext 
       Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity 
       Dim cpr As New copyProgress(AddressOf FileCopyProgress) 
       Dim destinationDir As DirectoryInfo = New DirectoryInfo("c:\destination\") 
       Private Delegate Function copyProgress(ByVal totalFileSize As Int64, ByVal totalBytesTransferred As Int64, ByVal streamSize As Int64, ByVal streamBytesTransferred As Int64, ByVal dwStreamNumber As Int32, ByVal dwCallbackReason As Int32, ByVal hSourceFile As Int32, ByVal hDestinationFile As Int32, ByVal lpData As Int32) As Int32 
       Private Declare Auto Function CopyFile Lib "kernel32.dll" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As copyProgress, ByVal lpData As Int32, ByVal lpBool As Int32, ByVal dwCopyFlags As Int32) As Int32 
       Private Function FileCopyProgress(ByVal totalFileSize As Int64, ByVal totalBytesTransferred As Int64, ByVal streamSize As Int64, ByVal streamBytesTransferred As Int64, ByVal dwStreamNumber As Int32, ByVal dwCallbackReason As Int32, ByVal hSourceFile As Int32, ByVal hDestinationFile As Int32, ByVal lpData As Int32) As Int32 
       End Function 
       Private Function FileCopyProgress2(ByVal totalFileSize As Int64, ByVal totalBytesTransferred As Int64, ByVal streamSize As Int64, ByVal streamBytesTransferred As Int64, ByVal dwStreamNumber As Int32, ByVal dwCallbackReason As Int32, ByVal hSourceFile As Int32, ByVal hDestinationFile As Int32, ByVal lpData As Int32) As Int32 
       End Function 
       Sub Main() 
          Try 
             currentWindowsIdentity = CType(System.Security.Principal.WindowsIdentity.GetCurrent, System.Security.Principal.WindowsIdentity) 
             impersonationContext = currentWindowsIdentity.Impersonate() 
             Console.WriteLine("Name: " & currentWindowsIdentity.Name) 
             Console.WriteLine("IsAuthenticated: " & currentWindowsIdentity.IsAuthenticated) 
             Console.WriteLine("User: " & currentWindowsIdentity.User.ToString) 
             Console.WriteLine("AuthenticationType: " & currentWindowsIdentity.AuthenticationType) 
             If Not destinationDir.Exists Then 
                Console.WriteLine("Destination directory doesn't exist, creating new directory..") 
                destinationDir.Create() 
             End If 
             CopyFile(Path.Combine("\\192.168.100.1\share\", "example.exe"), Path.Combine("c:\destination\", "example.exe"), cpr, 0, 0, 0) 
          Catch ex As Exception 
             Console.WriteLine(ex.ToString) 
          Finally 
             Console.WriteLine("Undoing impersonation..") 
             impersonationContext.Undo() 
          End Try 
          Console.ReadKey() 
       End Sub 
    End Module 

  • I have a passport external hard. previously, I used it on windows, then I changed my laptop to mac. Now, It's only read. How can I use it for copying files on it on mac? I don wanna use it on windows again.

    I have a passport external hard. previously, I used it on windows, then I changed my laptop to mac. Now, It's only read. How can I use it on my mac for copying files on my passport? I don wanna use it on windows again.

    If you're not going to use the drive on a Windows machine, you should use Disk Utility (Applications>Utilities folder) to erase the drive and format it as "Mac OS Extended (Journaled)" with a single GUID partition (default):
    Good luck,
    Clinton

  • Using scp to copy files from remote server to mac from a newbie

    Hi am a new poster to this forum and getting (re)acquainted with the unix world using terminal on the Mac. I am part of webteam for a large website run by a nonprofit where I have administrative access. I hope that this forum is the correct venue for my question.
    The other day I used terminal tsch to logg onto a remote server where I have admin privaleges. One of the other admins and I were in the process of experimenting with using either rsync or scp to "backup" the server. We are experimenting with different backup strategies over and above those supplied by our web host. After finding out how to open port 22 on my modem and setting services in sharing to allow for remote log on, I logged on to the remote server and ran this command (suggested by another admin):
    scp -r -p -v /remotefolder [email protected]:/Users/drktyler/Documents/serverBU/
    Unfortunately I had severely underestimated the amount of time it would take to perform scp and needed to terminate the scp job. For example, I only got 100 MB onto my Mac in one hour (normally takes about 6 mintues to download a 100 MB file from the internet) I tried to kill the job by doing:
    ctrl -z
    ls ps
    kill (scp pid #)
    This did not work. And I forgot about trying ctrl-c <blush>
    I was able to exit my session on the remote server which "exited" the scp job.
    Oh, before running scp, I did try rsync and it did not work. Unfortunately, I had not set my terminal session to an unlimited buffer size, so the early part of my session rolled off the terminal screen. This means I have no idea what the error was.
    This morning the other admin was performing some backups on the remote server and noticed that there was a an unexplained directory on the remote server named:
    mymacuserid
    It had what he called some rpms. I am not exactly sure what a rpms cache files are, but I think that rpms has some relatationship to the RPM package manager used by many linux systems. I could not account for how the mymacuserid directory got on the remote server because I did not put it there and my log in id to the remote server bears no resemblance to my Mac user id.
    We don't believe that this directory did any harm to the remote server, but I sure as heck would like to know how it got there.
    My question is if there was something about my scp command that
    (1) created this "temporary" mymacuserid directory on the remote server
    (2) did the way I ended the scp job by exiting the terminal mean that this temporary directory was not "cleaned up."?
    (3) what other options might have been available to me to kill the job and clean up after the job? ctrl-c while logged onto the remote server? opening up a second terminal window and killing the ssh job?
    (4) is scp normally that slow?
    My Mac: Mac Mini, 1.66 GHz Intel Core Duo, Memory: 1.5 GB 667 MHz DDR2 SDRAM, Mac OS 10.4.8
    Remote server: CPU AuthenticAMD, AMD Athlon(TM) XP 2600+
    Version psa v8.1.1_build81070716.12 os_CentOS 4.2
    OS Linux 2.6.9-55.0.2.EL {CentOS is built from Red Hat Enterprise Linux}
    Respectfully yours,
    treehugger from nj

    J.V. Thanks so much for your very helpful response!
    The other admin who was trying scp over the weekend also reported that the job ran very slowly, so I suspect the slow response time may be on the remote server end. I do appreciate knowing that you have gotten 80% of your advertised DSL speed with scp.
    Thank-you for being so polite and gentle in your response. No I did not know that if the remote patname has white space in it, that I need to quote the whole path and escape any white space with preceding backslashes as you showed in your rsync example.
    Finally, as for the rogue elements being left on the server, I figured out that these rogue elements were left on the server the day before I did the aborted scp job because I had to quit the terminal in the middle of an active rsync job while logged onto the remote terminal. When I went onto the server this morning, I checked the timestamps on the rogue files and the timestamps match up.
    The other admin has finally succeeded in doing a full server back-up (in addition to the back-up using the back-up utility provided by our web host). So, for the moment we are in pretty good shape. Of course, I'm not sure that I could replicate what he did. <shrug>
    Thanks again. I'm glad I posted on this forum as I have always learned a lot by reading the apple forums I suspect that I will be posting again.
    T.H.
    P.S. Please forgive me for not including copies of your original message in my reply. There is probably a setting that I need to change.

  • Using Automator to copy files from a Windows network

    This has been covered before, but the solution didn't work for me, so excuse the mainly copy-and-paste article:
    I wrote an automator workflow to copy a chosen file located on a PC on the local network.
    Here is the workflow:
    Get Specified Servers
    Mount Servers
    Ask for Finder Items
    Copy Finder Items
    The workflow executes fine up until the workflow actually finishes copying all the files. The automator complains that the Copy Finder Items errors with the following message:
    Can't read directory contents: /Volumes/Files
    The other thread suggests choosing "Ignore Input" for the "Ask for Finder Items" action, which I did. But now I have a different error:
    Couldn't create: /Users/{my name}/Desktop/filename.xlsx
    Any ideas? Thanks!

    This has been covered before, but the solution didn't work for me, so excuse the mainly copy-and-paste article:
    I wrote an automator workflow to copy a chosen file located on a PC on the local network.
    Here is the workflow:
    Get Specified Servers
    Mount Servers
    Ask for Finder Items
    Copy Finder Items
    The workflow executes fine up until the workflow actually finishes copying all the files. The automator complains that the Copy Finder Items errors with the following message:
    Can't read directory contents: /Volumes/Files
    The other thread suggests choosing "Ignore Input" for the "Ask for Finder Items" action, which I did. But now I have a different error:
    Couldn't create: /Users/{my name}/Desktop/filename.xlsx
    Any ideas? Thanks!

  • Can I use the same tpz file from PI 7.0 to PI 7.1 ?

    I have configured JDBC sender (Oracle 10.2) to ABAP proxy receiver scenario using PI 7.0
    The customer now wants to install PI 7.1 and they want this to be a fresh installation, not an upgrade.
    If I export my configurations to the tpz, can I import the same in PI 7.1 as it is?
    Also, please let me know is there are any other risks that I should consider.
    Thanks and Regards,
    Prasad

    I was able to get some helpful answers in this thread
    PI 7.0  & PI 7.1
    What I understand is that it is mostly prossible but minor adjustments may be required. I guess I will understand the intricacies when it is actually done.
    Thanks all for your replies. I have awarded points for the helpful answers.

  • Can I use an unlocked iphone 4s from USA in Spain? Does it gonna work with a different frequency?

    I want a iphone 4s unlocked. Can I buy it on the United States and use on Spain? I listened that the frequency is different on this countries, and that the phone may doesn't work. I want to know it.
    Thank you so much

    The iPhone 4S will certainly work in Spain, even if purchased in the US.  Keep in mind, however, that warranty service is limited to the country of purchase.  Youll have to send your phone to someone in the US to bring into Apple if your phone needs warranty service.
    In addition, there is VERY limited availbility of the unlocked iPhone 4S in US Apple stores, if they're even available at all.  At this point, they're really only available online directly from the Apple Store

  • Using ARD to copy files remotely?

    Hi,
    I was thinking it is possible to use ARD to copy files from my home imac, when I am in the office using my macbook? Or this can only be done when I am on the same network? Thanks in advance.

    Should work fine provided you have ARD fully working between the two sites.

  • Drag and drop the file from document library to desktop in sharepoint 2013

    can we drag and drp the file from document library to desktop in sharepoint 2013
    Blitz

    We are using third party tool called PageLight for
    SharePoint Outlook Integration which provides drag and drop functionality of emails from Outlook to SharePoint.  Other features includes
    Save Outlook emails to SharePoint and also moving files/folders from file share.
    Thanks
    Alfred

  • How can i copy files from one external hard disk to another using macbook pro with retina display

    How can i copy files from one external hard drive to another using macbook pro with retina display?

    That's odd - if you open Disk Utility (Applications->Utilities) and select the disk(s), how are they formatted? If you're only going to be used with your Mac, they should be formatted as "Mac OS Extended (Journaled)".
    Clinton

  • Can't copy file from SAP-directory to FTP server

    Hello,
    I can't copy files from the SAP server to the FTP server. The file is created with OPEN DATASET and CLOSE DATASET commands and is placed in the SAP-directory S:\usr\sap\DEV\DVEBMBGS00\work.
    I can see and read the file with transaction al11, so I know it's there.
    But the FTP command always gives the same error:
    S:\usr\sap\DEV\DVEBMBGS00\work\[FILENAME] errno 22: invalid argument
    I can connect to the FTP, but the put command keeps failing. Somehow, the file in the SAP directory can't be read, it seems, even when
    Any ideas?
    Thanks in advance.
    Dave

    Ok, I found out that I have to use SAPFTPA as RFC destination type, instead of SAPFTP, otherwise the folders can't be located.
    But with SAPFTPA I can't seem to connect to the FTP server. I've tested the connection with sm59 and it works, but for the FTP it doesn't work. When I use SAPFTP as destination type, it still works.
    What can I do?
    Thanks.

  • Can't copy files from NTFS volume with Read Only permissions?

    I am trying to copy files from an NTFS volume used previously for Windows onto another volume which is Mac OS X Extended...
    However, certain files fail to copy due to the fact that I 'don't have permission to access some of the items'...
    So I found the items which are causing the issue and viewed the permissions for them which display as 'You can only read'... I presume I am correct taking these as read-only permissions which (to my knowledge) should allow the files/folders to be copied accross to a new volume assuming that the existing volume is left without any changes attempted.
    So can anyone suggest to me why this is? And how I might rectify the issue?
    Thanks in advance

    Ok I've just worked out that 'You can only read' is referring to the fact that I can only view permissions but not add any. Below this statement, no permissions are listed which may explain why I cannot access the files but does not explain why I can copy/access some files, also with no permissions...

Maybe you are looking for