Bigcommerce API product images - php

I am able to upload products to my Bigcommerce store via the API with no problem, but I want to link those products to images that I have already uploaded via WebDav-the images are currently in the 'upload' folder. How do I do this?
When I upload products via a CSV file, all I do is have a column labeled 'Product Image File', which contains the file name of the image that is residing in the 'upload' folder. When products are created this way, Bigcommerce will automagically link the products with the associated images.
End goal is to use the API for product creation, and tell Bigcommerce which image file to use that has been uploaded via WebDav, in advance.

The main thing to note in regards to adding images via API is that it must be done in a separate request from the creation of the product, unlike when importing by CSV. Your script should first create the product and capture the ID of the newly created product from the response BC gives you. Once you have that ID you can add an image by following the "create a product image" POST method described on this page:
https://developer.bigcommerce.com/api/stores/v2/products/images
You can only add one image per POST request.
The full path to the image (including http://) will be added to the image_file parameter of the object you pass in your POST request body. This is the only parameter that must be passed when creating an image but there are other things you can pass along as well if you choose.
If the images that you have uploaded to the Webdav server of your store are placed into the /product_images/import/ folder then you can reference the image in the image_file parameter by just the name of the image with it's extension (ie: image_name.jpg) just like in a CSV import. You stated that you uploaded your images to an 'upload' folder though, if that is the case you must use the full HTTP path to the image.

The image file path has to be relative to the 'import' directory:
https://developer.bigcommerce.com/api/objects/v2/product_image
When specifying a product image, the image_file should be specified as
either: A path to an image already uploaded in the import directory
and the path should be relative from the import directory or a URL to
an image accessible on the internet.

the same problem I was facing, i was trying to upload an image in a product using V3 API, but show errors 422 "image URL must be preset if uploading image by URL", my image is present in WEBDEV server,
file path: /dav/product_images/import/abc.jpeg
I was trying to upload an image URL with API Body
{
"description": "Top View upload",
"image_url": "https://store-xxxxxxxxxxxx.mybigcommerce.com/dev/product_images/import/abc.jpeg",
"is_thumbnail": true,
"sort_order": 1
}
it was showing error,
so I download Cyberduck to connecting to my WebDAV server, I create a connection
https://support.bigcommerce.com/s/article/File-Access-WebDAV
after connecting my store server with Cyberduck, I open folder "product_images/import/abc.jpeg"
then right-click on and click on "Open URL" copy URL and paste it in API image_url value
Issue: please use the following URL structure if upload image URL from Webdev :
https://store-url/product_images/import/image_name.jpg
Eg. https://store-abcdefghijk.mybigcommerce.com/product_images/import/abcd.jpg
i was using the wrong path i.e.
https://store-abcdefghijk.mybigcommerce.com/dev/product_images/import/abcd.jpg
if you are using dev in the image URL please remove it

Related

How to secure user's images on a server?

My web application is really simple. There are two buttons: one called "save" and the other called "show my images".
Basically, the user can save images from the Facebook API and store them in the server folder called "backup" (to back up their images on the server so if they deleted their FB or image from FB they will have backup).
When the user clicks "save", the images will be stored in two locations. The image URL will be stored in SQL database, but it will also be saved on server folder called "backup"
When they click "show images", it will retrieve the image's URL from the database and display the image. However when checkImage() is called, it will check if the image URL is valid. If it's invalid, it will retrieve the same image from the server folder "backup".
I don't want the admin to access the backup folder and be able to see all the user's images.
Before the images get saved in the backup folder on server I want to encode the user images and when they request the image it will decode and be displayed.
Is this possible?
The reason that I want to do this is because I'm worried that the FB image URL will be broken and thus the image will not show on the website.
function checkImage($url) {
if (#getimagesize($url)) {
echo "image exists ";
} else {
echo "image does not exist";
}
}
Yes it is possible and it is good thing to do
I have worked already on these kind of system, i have worked on sites similar to google drive or dropbox , and the security/ privacy for user's files comes at first and the point you are making is very much valid and reasonable.
Let me explain you what you can do to make this possible so even if admin / anyone have ftp access to the folder he / she will not be able to see the images at all.
When you save the images to your database , and you save also the link of facebook to check if it's valid or not , save also the following informations from the image to use them later on for decryption of images.
File size
Image type
Image extension
Image Original name
Image encrypted name
Image path
Image user
User path
Now let me explain you what these columns would mean to your system.
File size would be obviously the size of the image you are saving to your server in case you need the informations for insights of your server.
Image type should be the type of file which is like : image/jpeg or image/png
Image extension Should be the extension of image , which you will need to use for decrypting the image inside your system.
Image original name should be also used for system to decrypt the image to show the original image name
let say image original name + image extension will be used inside headers function for php.
Image encrypted name , this will be a random string without file extension for example :
let say you have a image named : myimage.jpeg , now what you will do is save the original file name and extension into database , then while using the move_uploaded function of php to move the file into folder of user (folder can be also unique random string for every user), then just rename the file inside upload process to something like 823982j3kkj2hjh3j2h323hj2h3jh23jh just a random string without extension inside a random string named folder which is associated to the user which even user doesn't know and save this random string name along with image 's other details and later on you will need to to identify the image and rename it to original one with extension.
Image path should be the complete path to the image folder , you need this to identify the folder where you stored the image
Image user this is obviosuly a user's id
User path this is a random string named folder where image will be stored
in this way , you will encrypt the image and it will be only visible to the user only from the system's functionality, even admins will not be able to identify the folder or files that are conncted to the users and files will be saved without extension and without original name , so only system will be able to decrypt it.
i hope i have given you an idea on how you can do it.

Tinymce imagetools image not showing

so I started using tinymce for my blog posts and there is this problem with imagetools, they work while images are being edited, but after the article is posted, only this BIG url is showing. I think the problem is that, the blob image which is created while editing is not saved and I need to save it, right?
By the way I am using laravel.
When you edit images using the image tools they will always be turned into a Base64 or BLOB encoded image - the image tools function in the browser and know nothing (directly) of the application in use (e.g. Laravel). As such its up to the application to determine what to do with these images:
https://www.tinymce.com/docs/advanced/handle-async-image-uploads/
The basic process is that TinyMCE will create a separate HTTP POST for each image that you modify with the image editor. It will send that image to a URL of your choosing (via HTTP POST) based on the setting of the images_upload_url option in your init.
The image handler at the URL referenced in the images_upload_url (which you have to create) has to do whatever needs to be done to "store" the image in your application. That could mean something like:
Store the item in a folder on your web server
Store the item in a database
Store the item in an asset management system
I would assume Laravel has some APIs such as the Filesystem API that you could use to store the images appropriately.
Regardless of where you choose to store the image your image handler needs to return a single line of JSON telling TinyMCE the new location of the image. As referenced in the TinyMCE documentation this might look like:
{ location : '/uploaded/image/path/image.png' }
TinyMCE will then update the image's src attribute to the value you return. If you use the images_upload_base_path setting in the init that will be prepended to the returned location.
The net here is that TinyMCE knows when an embedded image exists in your content but it can't possibly know what to do with that image in the context of your application so that job (the "image handler") is something you must create.

thumbnail creation in PHP

I want to create a thumbnail from a bigger image. Therefore I used a script from a german tutorial found at http://www.php-resource.de/tutorials/tutorial,24,Thumbnails-mit-PHP-erzeugen,1.htm
The creation of a thumbnail from the hdd works nicely but i want to create a thumbnail from a image received by a http post request. ($inputImage = file_get_contents('php://input');)
Problem is that in the script the image is accessed from the local disk using the path.
eg. $size=getimagesize("PicPath/picName");
Can I access the image saved in the $inputImage variable?

Joomla 3.0 custom video and image URL upload option

i have a joomla 3.0 component for movies sales (PICSELL) but i want to add an option where i can choose to upload movies using (Custom URL to upload movie and Images) the component already has file manager where to upload movies,images,prices,movie type (zip file or flv) and i want to add an option to it so that ones i put the url it will call both video and image from my server due to uploading problems and internet connection problem by uploading from file manager.while adding the URL option other information should be same in the file manager.so the option button will be shown ontop of the file manager to choose between uploading via file manager or via URL
how do i do that? what code will i use and where to use the code?
You want load videos from upload file or url path
i see the documentation and using multiple site.
Its totally free
General Video : Select when you upload video from your hard disk or
through a direct video file path
I have suggest yendif player

Upload Plugin Cakephp

I'm new in CakePHP and trying to learn but I don't understand this part very well..
I'm using this CakePHP Upload plugin to upload images for users(avatars) and using imagick it resize image to certain sizes(thumbs)...
I follow Upload plugin instructions for uploading image. I manage to store image file and image directory in database. So column photo in database would be (imagename.jpg) and photo directory would be userid,
for example (35). Image also appear in files/user/userid/imagename.jpg
Now may be it's funny but how I output this image and display in view file ? Also is there possibility to randomize file name ? (so the file name is not same as uploaded)
to view your upload in view files of CakePHP
you write in ctp files like
$html->link($html->image('files/user/".$userId."/".$ImageName."', array('alt'=>"User Image", 'border'=>"0"))
,'#',array('id'=>$userId, 'escape'=>false));
let me know if i can help you further,

Categories