react-native-photo-editor icon indicating copy to clipboard operation
react-native-photo-editor copied to clipboard

After Saving File Get Error in IOS

Open arjundalal opened this issue 4 years ago • 7 comments

Hello Team, after pressing the done button on IOS it will give me an error message. i have followed folllowing steps:

  1. i will get image link from server side.
  2. using RNFetchBlob i will store this image into local and get the following path: /var/mobile/Containers/Data/Application/C1AD606B-A508-4994-9736-5647350402FB/Documents/21_1_2020_15_36_22.jpg
  3. after doing proper changes when i press on DOne Button it will give me an error messsage. The error is as follows: Missing request token for request: <NSURLRequest: 0x283415040> { URL: file:///var/mobile/Containers/Data/Application/C1AD606B-A508-4994-9736-5647350402FB/Documents/21_1_2020_15_36_22.jpg }

Please help me to resolve this issue.

arjundalal avatar Jan 22 '20 08:01 arjundalal

Are you using RNFS to seek the file path?

prscX avatar Jan 22 '20 09:01 prscX

yes

arjundalal avatar Jan 22 '20 09:01 arjundalal

var month = new Date().getMonth() + 1; var timestamp = new Date().getDate() + '' + month + '' +new Date().getFullYear() + '' + new Date().getHours() + '' + new Date().getMinutes() + '_' +new Date().getSeconds(); this.props.greetingStore.setUploadFileID(greeting_id); let photoPath = RNFS.DocumentDirectoryPath + '/' + timestamp + '.jpg'; RNFetchBlob.config({fileCache: true}) .fetch('GET', image_url) .then(resp => { RNFS.moveFile(resp.path(), photoPath) .then(() => { this.props.greetingStore.setgenrate_local_image_url('success'); this.methodcall(photoPath); }) .catch(err => { this.props.greetingStore.setgenrate_local_image_url('failed'); console.log('203 line greeting error::', err.message); }); }) .catch(err => { this.props.greetingStore.setgenrate_local_image_url('failed'); console.log('208 line greeting error::', err.message); });

this is my code

arjundalal avatar Jan 22 '20 09:01 arjundalal

Looks good, could you share snippet of invoking the library Edit API, please.

prscX avatar Jan 22 '20 10:01 prscX

here we call the library for open: methodcall(image_url_path) { RNPhotoEditor.Edit({ path: image_url_path, stickers: Platform.OS === 'ios' ? [] : GREETING_STICKERS,

  hiddenControls: [],
  colors: GREETING_COLOR,
  onDone: response => {
    console.log('on done');
    console.warn('response::', image_url_path);
    this.props.greetingStore.saveFileToServer(
      Platform.OS === 'ios' ? image_url_path : response,
    );
  },
  onCancel: () => {
    console.log('on cancel');
  },
});

}

arjundalal avatar Jan 22 '20 10:01 arjundalal

image path URL return me like this /var/mobile/Containers/Data/Application/D61C7F96-7F7C-457F-A928-F8787073BB85/Documents/22_1_2020_14_7_58.jpg

arjundalal avatar Jan 22 '20 10:01 arjundalal

saveFileToServer(filepath) { this.upload_file_status = 'pending'; this.loader_Status = true; var data = new FormData(); data.append('photo', { uri: 'file://' + filepath, // your file path string name: 'my_photo.jpg', type: 'image/jpg', }); fetch(DEFAULT_IMAGE_UPLOAD, { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'multipart/form-data', Authorization: Bearer ${GET_ASYNC_STORE.USER_ACCESS_TOKEN}, }, body: data, }) .then(response => response.json()) .then(responseJson => { runInAction(() => { this.upload_file_status = 'success'; this.loader_Status = false; var artCategoryId = responseJson[0].artCategoryId; this.saved_file_name = responseJson; console.log('Saved File Name:::', this.saved_file_name); this.saved_file_id = this.upload_file_id; }); }) .catch(error => { this.upload_file_status = 'failed'; this.loader_Status = false; console.error(error); }); }

this is an API Call

arjundalal avatar Jan 22 '20 10:01 arjundalal