uploading a file to sharepoint using your phpSPO library

I saw from one of your previous post that you are an author of phpSPO. I came across your phpSPO library earlier this month while trying to access sharepoint by php.

I went through your GitHub and saw the samples but with my limited knowledge on sharepoint, I only manage to get myself authenticated with sharepoint using my account, but I don’t know how to say upload a file into sharepoint.

are you able to give me a simple example how to upload a file into sharepoint using your phpSPO library?

Error while uploading password protected file in IRM Enabled library

I am trying to upload a password protected PDF file in a document library which is IRM enabled and while uploading the file I am getting below error.

The PDF document you tried to upload was not encrypted in SharePoint therefore it cannot be uploaded to this library.

Is there any link which says that password protected documents are not allowed in IRM enabled document library.

Error in Uploading Image using REST API in Magento 2

I am getting below error while hit REST API from postman:

“message”: “The product can’t be saved.”,

I have used below details for API:

URL: magento.localhost/rest/V1/products/p1/media

HEADERS :

Content-Type:application/json

Authorization:Bearer 1si2ch4k8to78ytx14is8gcgfs4p3glk

BODY

{      "entry":{         "id":153,       "media_type":"image",       "label":"test",       "position":0,       "disabled":true,       "types":[            "image"       ],       "file":"test.png",       "content":{            "base64_encoded_data":"base64_encoded_data",          "type":"image/png",          "name":"new image"       }    } } 

Can anyone please help me in this? I tried lot of thing but nothing is working.

Uploading ECommerce products into your Website for $20

If you are looking for someone to add woocommerce I’m here to help you!!!  My Priority is to provide you fast and Quality service.I will add woocommerce products on your store. My first priority is your 100% satisfaction. I will Provide Services of: * 100 woocommerce Products with Pictures, Price and Description etc.  * Woocommerce Product Title  * Long Description and Short Description   * Price/special price  * Category/sub-categories  * Tags/Key words  * SKU Some reason why you hire me?? Quick ResponseDelivery before deadlineExperience100 % Quality and time Guaranteed100% Moneyback Guarantee If you do not get the satisfaction with my work .

by: SwarupMajumder
Created: —
Category: Data Entry
Viewed: 32


503 Service unavailable while uploading file on SharePoint online of size more than 249 MB

I am trying to upload the file on SharePoint online larger than 250MB using rest API. I have divided data of the file in small chunks say 100MB and used Start upload, continue Upload and Finish Upload of SharePoint. I am getting 503 services exactly after it writes 249 MB. However, The below code runs successfully for the file size up to 249MB. According to SharePoint online documentation, we can upload files of size up to 2GB. Any leads or help is much appreciated.

Thanks,

Bharti Gulati

package test;  import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List;  import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.ParseException; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.json.JSONObject;  public class SampleFileUpload1 {     private final static int chunkSize = 100 * 1024 * 1024;      public static void main(String args[]) throws IOException {         SampleFileUpload1 fileUpload = new SampleFileUpload1();         File file = new File("C:\users\bgulati\Desktop\twofivefive.txt");         fileUpload.genereateAndUploadChunks(file);     }      private static void executeRequest(HttpPost httpPost, String urlString) {         try {             HttpClient client = new DefaultHttpClient();             HttpResponse response = client.execute(httpPost);              System.out.println("Response Code:  " + response.getStatusLine().getStatusCode());             System.out.println("Response getReasonPhrase:  " + response.getStatusLine().getReasonPhrase());             System.out.println("Response getReasonPhrase:  " + response.getEntity().getContent().toString());             BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));              while (true) {                 String s = br.readLine();                 if (s == null)                     break;                 System.out.println(s);             }         } catch (UnsupportedEncodingException e) {             e.printStackTrace();         } catch (ClientProtocolException e) {             e.printStackTrace();         } catch (IllegalStateException e) {             e.printStackTrace();         } catch (IOException e) {             e.printStackTrace();         }     }      public static void executeMultiPartRequest(String urlString, byte[] fileByteArray) throws IOException {         HttpPost postRequest = new HttpPost(urlString);         postRequest = addHeader(postRequest, "accessToken");         try {             postRequest.setEntity(new ByteArrayEntity(fileByteArray));         } catch (Exception ex) {             ex.printStackTrace();         }         executeRequest(postRequest, urlString);     }      private static HttpPost addHeader(HttpPost httpPost, String accessToken) {         httpPost.addHeader("Accept", "application/json;odata=verbose");         httpPost.setHeader("Authorization", "Bearer " + accessToken);         httpPost.setHeader("Content-Type", "application/json;odata=verbose;charset=utf-8");         return httpPost;     }      private static String getUniqueId(HttpResponse response, String key) throws ParseException, IOException {         if (checkResponse(response)) {             String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");             JSONObject json = new JSONObject(responseString);             return json.getJSONObject("d").getString(key);         }         return "";     }      private static boolean checkResponse(HttpResponse response) throws ParseException, IOException {         if (response.getStatusLine().getStatusCode() == 200 || (response.getStatusLine().getStatusCode() == 201)) {             return true;         }         return false;     }      private String createDummyFile(String relativePath, String fileName) throws ClientProtocolException, IOException {         String urlString = "https://siteURL/_api/web/GetFolderByServerRelativeUrl('"+relativePath+"')/Files/add(url='" +fileName+"',overwrite=true)";         HttpPost postRequest = new HttpPost(urlString);         postRequest = addHeader(postRequest, "access_token");         HttpClient client = new DefaultHttpClient();         HttpResponse response = client.execute(postRequest);         return getUniqueId(response, "UniqueId");     }      private void genereateAndUploadChunks(File file) throws IOException {         String relativePath = "/relativePath";         String fileName = file.getName();         String gUid = createDummyFile(relativePath, fileName);          String endpointUrlS = "https://siteURL/_api/web/GetFileByServerRelativeUrl('"+relativePath+"/"+fileName+"')/savebinarystream";         HttpPost postRequest = new HttpPost(endpointUrlS);         postRequest = addHeader(postRequest, "access_token");         HttpClient client = new DefaultHttpClient();         HttpResponse response = client.execute(postRequest);          long fileSize = file.length();         if (fileSize <= chunkSize) {          }          else {             byte[] buffer = new byte[(int) fileSize <= chunkSize ? (int) fileSize : chunkSize];              long count = 0;             if (fileSize % chunkSize == 0)                 count = fileSize / chunkSize;             else                 count = (fileSize / chunkSize) + 1;             // try-with-resources to ensure closing stream             try (FileInputStream fis = new FileInputStream(file);                 BufferedInputStream bis = new BufferedInputStream(fis)) {                 int bytesAmount = 0;                 ByteArrayOutputStream baos = new ByteArrayOutputStream();                 int i = 0;                 String startUploadUrl = "";                 int k = 0;                 while ((bytesAmount = bis.read(buffer)) > 0) {                     baos.write(buffer, 0, bytesAmount);                     byte partialData[] = baos.toByteArray();                     if (i == 0) {                         startUploadUrl = "https://siteURL/_api/web/GetFileByServerRelativeUrl('"+relativePath+"/"+fileName+"')/StartUpload(uploadId=guid'"+gUid+"')";                                                executeMultiPartRequest(startUploadUrl, partialData);                         System.out.println("first worked");                         // StartUpload call                     } else if (i == count-1) {                         String finishUploadUrl = "https://siteURL/_api/web/GetFileByServerRelativeUrl('"+relativePath+"/"+fileName+"')/FinishUpload(uploadId=guid'"+gUid+"',fileOffset="+i+")";                         executeMultiPartRequest(finishUploadUrl, partialData);                         System.out.println("FinishUpload worked");                         // FinishUpload call                     } else {                         String continueUploadUrl = "https://siteURL/_api/web/GetFileByServerRelativeUrl('"+relativePath+"/"+fileName+"')/ContinueUpload(uploadId=guid'"+gUid+"',fileOffset="+i+")";                         executeMultiPartRequest(continueUploadUrl, partialData);                         System.out.println("continue worked");                     }                     i++;                 }             }         }      } } 

Uploading product images

Im creating a site where a user can upload multiple(multiselect) product images at once.

My question is what would be the the “right” way if the user uploads images that have the same name as the ones that are already in the destination folder.. Should I just override the existing one´s with the new images or just add the ones that have not the same name and skip the existing ones.. perhaps prompt the user about it? Im leaning towards overriding the existing one´s..

Thanks in advance

Uploading product images

Im creating a site where a user can upload multiple(multiselect) product images at once.

My question is what would be the the “right” way if the user uploads images that have the same name as the ones that are already in the destination folder.. Should I just override the existing one´s with the new images or just add the ones that have not the same name and skip the existing ones.. perhaps prompt the user about it? Im leaning towards overriding the existing one´s..

Thanks in advance